a survey of uc/os & lwip
DESCRIPTION
A survey of uC/OS & lwIP. 蔡嘉泰 [email protected]. MicroC/OS II. Features. Source Code Open Source ,程式碼簡潔易懂 Portable 程式碼大部分皆是利用 ANSI C 所開發的 與 microprocessor 行為有關的則利用組合語言來完成,使得 uC/OS-II 能夠輕易的移植到其他 Processor uC/OS-II 可以在 8/16/32 bits 的 microprocessor 上或是 micro-controller 上運作. Features. - PowerPoint PPT PresentationTRANSCRIPT
![Page 2: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/2.jpg)
NETLAB
MicroC/OS II
![Page 3: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/3.jpg)
NETLAB
Features
Source Code Open Source,程式碼簡潔易懂
Portable 程式碼大部分皆是利用 ANSI C所開發的 與 microprocessor行為有關的則利用組合語言來完成,使得 uC/OS-II能夠輕易的移植到其他 Processor uC/OS-II可以在 8/16/32 bits 的 microprocessor上或是micro-controller上運作
![Page 4: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/4.jpg)
NETLAB
Features
ROMable 只要有適當的工具 (C compiler, assembler and
linker/locator)就可將 uC/OS-II嵌入成為產品一部分 Scalable
可以很簡單的選用程式 /產品所需要的特性 也就是說可以依照自己的需求減少程式的大小,以便可以放入 ROM/RAM中
![Page 5: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/5.jpg)
NETLAB
HIGH Priority Task
LOW Priority TaskISR(1) (2)
(3)(4)
(5)
(6)
(7)
ISR makes the high priority task ready
Time
Features
Preemptive uC/OS-II 永遠會讓已經 Ready且優先權最高的工作行程先執行
![Page 6: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/6.jpg)
NETLAB
TASKWAITING
TASKDORMANT
TASKREADY
TASKRUNNING
ISRRUNNING
Features
![Page 7: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/7.jpg)
NETLAB
Features
Multi-tasking uC/OS-II最多可支援 64 個 task,其中會為系統保留8 個 task使用 每一個 task都有一個唯一的 priority,也就是說
uC/OS-II無法實現 Round Robin排程
![Page 8: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/8.jpg)
NETLAB
StatusSP
Priority...
Task Control Block
TASK #1Stack
SP
.
.
.
StatusSP
Priority...
Task Control Block
TASK #2Stack
StatusSP
Priority...
Task Control Block
TASK #nStack
……
MEMORYCPU
Features
![Page 9: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/9.jpg)
NETLAB
Features
Deterministic 在 uC/OS-II內的各項服務所需要的執行時間都是可明確預先得知的
Task Stacks uC/OS-II允許每一個 task擁有不一樣的 stack size 根據需要增減 task 的 stack size減少 RAM的使用
![Page 10: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/10.jpg)
NETLAB
Features
Services Mailbox, Queues, Semaphores, Fixed-sized
memory partitions, Time related function, etc. Interrupt Management
Interrupts can suspend the execution of a task 256 levels
Robust and Reliable
![Page 11: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/11.jpg)
NETLAB
uC/OS-II移植分析只要有相對應的 C Compiler,即可將 uC/OS-II移植到特定的處理器上大部分移植工作都在多任務的切換上
用來儲存以及恢復 register的值 利用組合語言完成
需修改的檔案 OS_CPU.H, OS_CPU_C.C, OS_CPU_A.S
![Page 12: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/12.jpg)
NETLAB
OS_CPU.H
定義DATA TYPE 與所使用的 Compiler相關 不同的 Compiler會使用不一樣的 byte來表示同一
DATA TYPE X86平台 , Integer:
• GNU (gcc): 4 bytes• MicroSoft (VC++): 2 bytes
![Page 13: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/13.jpg)
NETLAB
OS_CPU.H
Stack Entry 定義 TASK 的 Stack長度,必須要和 CPU 的
Register的長度一致堆疊增長方向
定義 Stack grows from HIGH to LOW or Low to HIGH Memory
![Page 14: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/14.jpg)
NETLAB
OS_CPU.H
![Page 15: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/15.jpg)
NETLAB
OS_CPU.H
中斷、 Content Switch
![Page 16: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/16.jpg)
NETLAB
OS_CPU_C.C
Initialize a Task‘s STACK 在堆疊增長的方向上定每一個需要保存的 Register位址
AXCXDXBXSPBPSIDIESDS
HIGH
LOW
![Page 17: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/17.jpg)
NETLAB
OS_CPU_C.C
![Page 18: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/18.jpg)
NETLAB
OS_CPU_A.S
OSStartHighRdy( ) 在 OSStart()啟動之後,負責從最高優先權任務的
TCB Control Block中獲得該任務的 Stack Point (SP)
OSCtxSw( ) 將前一 task 的 register保存到堆疊中,獲得最高優先
權 task 的 SP,將此 task 的 register恢復,使之繼續執行 OSIntCtxSw( )
中斷級的 Content Switch
![Page 19: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/19.jpg)
NETLAB
Handbook
![Page 20: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/20.jpg)
NETLAB
Hardware Abstraction Layer (HAL) Real-time kernel Interrupt handling Exception handling Choice of schedulers Thread support Rich set of synchronization primitives Timers, counters and alarms Choice of memory allocators Debug and instrumentation support
μITRON 3.0 compatible API POSIX compatible API ISO C and math libraries Serial, ethernet, wallclock and watchdog device drivers USB slave support TCP/IP networking stacks GDB debug support
![Page 21: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/21.jpg)
NETLAB
light weight IP (lwIP)
![Page 22: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/22.jpg)
NETLAB
lwIP簡介 lwIP一套可用於 embedded system 的 TCP/IP
protocol lwIP可以移植到各OS上,在沒有OS情形下也可以獨立運作
lwIP主要是為了保持 TCP Protocol的主要功能並減少對 RAM的使用
只需要幾十 K 的 RAM和約 40K 的 ROM就可以運作,使得 lwIP很適合在嵌入式系統中運作
![Page 23: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/23.jpg)
NETLAB
lwIP簡介
嵌入式系統開發板
lwIP (TCP/IP Protocol)
uC-OS II
Upper Layer Protocol (ULP)
![Page 24: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/24.jpg)
NETLAB
lwIP特性 IP including packet forwarding over multiple
network interfaces ICMP for network maintenance and
debugging UDP for datagram data TCP with congestion control, RTT estimation
and fast recovery/fast retransmit Specialized no-copy API for enhanced
performance Optional Berkeley socket API
![Page 25: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/25.jpg)
NETLAB
lwIP特性 lwIP將所有與硬體、OS 、 Compiler相關的部分獨立出來放置在 /src/arch下修改這一些相關檔案將 lwIP移植到 uC/OS-II上
![Page 26: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/26.jpg)
NETLAB
Application/ Management model
Protocol Stack
RTP, RTCP
UDP
IP
MAC
Physical
![Page 27: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/27.jpg)
NETLAB
TCP/IP與行程間的溝通
![Page 28: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/28.jpg)
NETLAB
SOCKET APIbindlistenconnectacceptrecvsendwriteclose
lwip_APIlwip_bindlwip_listenlwip_connectlwip_acceptlwip_recvlwip_sendlwip_writelwip_close
netconn_APInetconn_bindnetconn_listennetconn_connectnetconn_acceptnetconn_recvnetconn_sendnetconn_writenetconn_close
![Page 29: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/29.jpg)
NETLAB
application
socket API
lwip_bind …
netconn_bind …
driver
recv_buf_data
ethernetif_input
low_level_inpit
ip_input
tcp_input
tcp_process
tcpip_thread
api_msg_input
do_bind …
TASK 1 TASK 2 TASK 3
![Page 30: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/30.jpg)
NETLAB
TASK 1(application 1) TASK 2
(data input)
TASK 3(tcpip_thread)
mboxrecvmbox acceptmbox
Single Application
![Page 31: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/31.jpg)
NETLAB
TASK 2(data input)
TASK 3(tcpip_thread)
mbox
TASK 1(application 1)
recvmbox acceptmbox
TASK N(application N)
recvmbox acceptmbox
Multi Application
![Page 32: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/32.jpg)
NETLAB
API types
TYPE 1 BIND, LISTEN, CLOSE
TYPE 2 CONNECT
TYPE 3 SEND. WRITE
TYPE 4 ACCEPT, RECV
![Page 33: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/33.jpg)
NETLAB
TASK 1
TYPE 1
TASK 2mbox1 2
34
msg->type• API_MSG_BIND• API_MSG_LISTEN
![Page 34: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/34.jpg)
NETLAB
netconn_bind do_bindAPI_MSG_BIND
netconn_bind
mboxapi_msg_post sys_mbox_fetch
sys_mbox_postsys_mbox_fetch
tcp_bind
![Page 35: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/35.jpg)
NETLAB
netconn_listen do_listenAPI_MSG_LISTEN
netconn_listen
mboxapi_msg_post sys_mbox_fetch
sys_mbox_postsys_mbox_fetch
pcb->accpet = accept_function
![Page 36: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/36.jpg)
NETLAB
netconn_close do_closeAPI_MSG_CLOSE
netconn_close
mboxapi_msg_post sys_mbox_fetch
sys_mbox_postsys_mbox_fetch
tcp_close
![Page 37: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/37.jpg)
NETLAB
TYPE 2
TASK 1
TASK 2
mbox1
2msg->type• API_MSG_CONNECT
TASK 3
34
![Page 38: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/38.jpg)
NETLAB
netconn_connect
do_connect
pcb->connected = do_connectedpcb->state = SYN_SENTtcp_enqueue()tcp_output()
netconn_connect
tcp_input() , tcp_process()switch case: SYNSENTpcb->connected
do_connected
mboxapi_msg_post
sys_mbox_fetch
sys_mbox_post
sys_mbox_fetch
![Page 39: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/39.jpg)
NETLAB
TYPE 3
TASK 1 mbox1 2
34
msg->type• API_MSG_SEND• API_MSG_WRITE
TASK 2
udp_outputor
tcp_write
![Page 40: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/40.jpg)
NETLAB
netconn_send do_sendAPI_MSG_SEND
netconn_send
mboxapi_msg_post sys_mbox_fetch
sys_mbox_postsys_mbox_fetch
udp_output
![Page 41: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/41.jpg)
NETLAB
netconn_write do_writeAPI_MSG_WRITE
netconn_write
mboxapi_msg_post sys_mbox_fetch
sys_mbox_postsys_mbox_fetch
tcp_enqueuetcp_output
![Page 42: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/42.jpg)
NETLAB
TYPE 4
TASK 3TASK 112 acceptmbox
orrecvmbox
TASK 2mbox3 4
56
msg->type• API_MSG_RECV
![Page 43: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/43.jpg)
NETLAB
netconn_accept
in tcp_processpcb->accept
accept_functionnetconn_accept acceptmboxsys_mbox_postsys_mbox_fetch
![Page 44: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/44.jpg)
NETLAB
netconn_recv
recv_tcpnetconn_recv recvmbox
do_recvmboxAPI_MSG_RECV
in tcp_input()pcb->recv
sys_mbox_postsys_mbox_fetch
api_msg_post sys_mbox_fetch
sys_mbox_postsys_mbox_fetch
Let the stack know that we have taken the data
![Page 45: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/45.jpg)
NETLAB
Server
netconn_new
netconn_bind
netconn_listen
netconn_accept
netconn_recv
netconn_write
netconn_close
do_bind
do_listen
accept_function
recv_tcp
do_write
do_recv
do_close
mbox
acceptmbox
recvmbox
mbox
mbox
mbox
mbox
TASK 1 TASK 2 TASK 3
![Page 46: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/46.jpg)
NETLAB
Client
netconn_new
netconn_bind
netconn_connect
netconn_recv
netconn_write
netconn_close
do_bind
do_connect
do_connected
recv_tcp
do_write
do_recv
do_close
mbox
recvmbox
mbox
mbox
mbox
mbox
TASK 1 TASK 2 TASK 3
![Page 47: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/47.jpg)
An Implementation of RDMA
Student: Chia-Tai TsaiAdviser: Prof. Rong-Hong Jan
![Page 48: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/48.jpg)
NETLAB
Introduction 1/3
Network bandwidth bottlenecks Network hardware Network Protocol Performance End station performance
• CPU• The I/O bottlenecks
– Interrupts– TCP/IP checksum– Copies
![Page 49: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/49.jpg)
NETLAB
DMA
![Page 50: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/50.jpg)
NETLAB
RDMA
![Page 51: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/51.jpg)
NETLAB
Protocol Stack
![Page 52: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/52.jpg)
NETLAB
Experimental Model
![Page 53: A survey of uC/OS & lwIP](https://reader037.vdocuments.pub/reader037/viewer/2022100219/56814bf3550346895db8e402/html5/thumbnails/53.jpg)
Click to edit company slogan .