120 likes | 130 Views
This lab explores the concepts of inter-process communication and context switching in a real-time operating system environment. It includes exercises and discussions on implementing ID checking engines and front-end interfaces.
E N D
Lab8 REAL TIME OS-2_Experiment Speaker: Yung-Chih Chen Advisor: Prof. Chun-Yao Wang November 17, 2003 Department of Computer Science National Tsing Hua University
Outline • Lab – µC/OS-II • Context switch example • Using Inter-Process Communication (IPC) • Exercise & Discussion
Context switch • Open project “eg2” in ./Lab08/Code/SW/eg2/ with CodeWorrior • Repeat step 2 ~ 7 at Lab08-1 Building Program with μC/OS-II • Build and Run, you can see programs running on μC/OS-II in AXD console window
Using Inter-Process Communication (IPC)(1/5) This program does the very same thing as eg1 does. However, eg3 use one task for input and another task for output. Data is passed between tasks using Mailbox. • Open project “eg3” in ./Lab8/Code/SW/eg3/ with CodeWorrior • Repeat step 2 ~ 7 at Lab08-1 Building Program with μC/OS-II • Because multiple value are to be passed, declare a structure to hold the values • We will trace uC/OS-II IPC machenism, so link Debug target of uC/OS-II
Using Inter-Process Communication (IPC) (2/5) • Build project and start AXD for Debug • Set a break point near line 75 in Task1, where Task1 posts mail to the mailbox. • Use “Step In (F8)” to trace into the OSMboxPost(). The cursur should jump to OSMboxPost() function in “os_mbox.c”. • Next, use “Step (F10)” to trace how message is delivered from Task1 to Task2. • When you reach “OSSched()” function, use “Step in” again to trace into the scheduler.
Using Inter-Process Communication (IPC) (4/5) • When you reach “OS_TASK_SW()” function, use “Step in” again. • Finally, you reach Task2 near line 88. where Task2 pending on the mailbox.
Outline • Lab – µC/OS-II • Context switch example • Using Inter-Process Communication (IPC) • Exercise & Discussion
Exercise (1/2) Write an ID checking engine and a front–end interface. The checking rule is in the reference section. Requirements:The engine and front-end must be implemented in different task. The front-end interface can accept up to 64 entries of ID in each round. The program runs continuously round by round. User input: The amount of ID to be checked. The ID numbers Program output: The ID number Check result
Exercise (2/2) Example: (start of round) How many IDs to check: 2 Enter ID #1: A123456789 Enter ID #2: B987654321 === check result === A123456789 valid B987654321 invalid (end of round)
Discussion • Explain and describe executing process of eg2 • Write down your suggestions about this lab