LwIP

Started by tha, August 29, 2021, 09:15:30 AM

Previous topic - Next topic

tha



sys_init()  ต้องถูกเรียกก่อนสิ่งอื่น. เริ่มต้น the sys_arch layer.

tha



Sleep เป็นเวลาจำนวนที่ระบุของ ms

Sleep เป็นเวลาบาง ms. Timeouts จะไม่ถูกประมวลผลในขณะ sleeping.

Parameters
          ms           จำนวนของ milliseconds ที่ sleep


tha



The only thread function: สตาร์ท a new thread ที่ชื่อ "name" ที่มี priority "prio" ที่จะเริ่มการปฏิบัติงานของมันใน the function "thread()". The "arg" argument จะถูกส่งผ่านเป็น an argument ไปยัง the thread() function. The stack size ที่ใช้สำหรับ thread นี้คือ the "stacksize" parameter. The id ของ the new thread ถูกรีเทิร์น. ทั้งคู่ the id และ the priority เป็น system dependent. ข้อควรระวัง: แม้ว่าฟังชั่นนี้ส่งคืนค่า, มันต้องไม่ล้มเหลว (พอร์ตต้องถือสิทธิ์สิ่งนี้!)

Parameters
          name           human-readable name สำหรับ the thread (ที่ใช้สำหรับ debugging purposes)
          thread          thread-function
          arg               parameter ที่ส่งผ่านไปยัง 'thread'
          stacksize     stack size in bytes สำหรับ the new thread (อาจถูกละเลยโดย ports)
          prio              priority of the new thread (อาจถูกละเลยโดย ports)

tha

https://www.nongnu.org/lwip/2_1_x/group__sys__time.html



ส่งคืนเวลาปัจจุบันในหน่วย milliseconds, อาจเป็นเหมือนกับ sys_jiffies หรืออย่างน้อยขึ้นอยู่กับมัน. ไม่ต้องสนใจสำหรับการพันรอบ, สิ่งนี้ถูกใช้เฉพาะสำหรับความแตกต่างของเวลา. การไม่จัดให้มีใช้ฟังชั่นนี้หมายความว่าคุณไม่สามารถใช้บาง modules (ตัวอย่างเช่น. TCP timestamps, internal timeouts for NO_SYS==1).

tha

https://www.nongnu.org/lwip/2_1_x/group__sys__prot.html



Detailed Description

ใช้เพื่อป้องกันเขตแดนที่สั้นของ code จากการเข้าถึงพร้อมกัน.

     •   Your system เป็น a bare-metal system (บางทีพร้อมกับ an RTOS) และ interrupts อยู่ภายใต้ your control: จัดให้มีใช้
          สิ่งนี้เป็น LockInterrupts() / UnlockInterrupts()
     •   Your system ใช้ an RTOS ที่มีการจัดการอินเตอร์รัปต์ที่เลื่อนออกไปจาก a worker thread: จัดให้มีใช้เป็น a global mutex
          หรือ lock/unlock scheduler
     •   Your system ใช้ a high-level OS ที่มีตัวอย่างเช่น POSIX signals: จัดให้มีใช้เป็น a global mutex

tha



SYS_LIGHTWEIGHT_PROT define SYS_LIGHTWEIGHT_PROT ใน lwipopts.h ถ้าคุณต้องการ inter-task protection สำหรับบริเวณส่วนสำคัญ(วิกฤต)ที่แน่นอนในระหว่าง buffer allocation, deallocation and memory allocation and deallocation.

SYS_ARCH_DECL_PROTECT ประกาศ a protection variable. macro นี้จะมีค่าเริ่มต้นเพื่อกำหนดตัวแปรของ type sys_prot_t. ถ้าพอร์ตใดพอร์ตหนึ่งต้องการการจัดให้มีใช้งานที่แตกต่างกัน, ดังนั้นมาโครนี้อาจถูกกำหนดใน sys_arch.h.

tha



SYS_ARCH_PROTECT กระทำการ a "fast" protect. นี้สามารถถูกจัดให้มีใช้โดยการปิดการใช้งาน interrupts สำหรับ an embedded system หรือโดยการใช้ a semaphore หรือ mutex. The implementation ควรยอมให้มีการเรียก SYS_ARCH_PROTECT เมื่อถูกป้องกันแล้ว. The old protection level ถูกรีเทิร์นใน the variable "lev". มาโครนี้จะมีค่าเริ่มต้นเพื่อเรียก the sys_arch_protect() function ซึ่งควรถูกจัดให้มีใช้ใน sys_arch.c. ถ้าพอร์ตใดพอร์ตหนึ่งต้องการการจัดให้มีใช้งานที่แตกต่างกัน, ดังนั้นมาโครนี้อาจถูกกำหนดใน sys_arch.h.