📄 readme
字号:
This is an example of RTAPI semaphores between two real-timeprocesses. NOTE: The basic concepts of this example haven't changes sincethis was originally written, but some details have changed.See the notes below.The master process (master.c) creates a semaphore,'master_sem', and runs a period timer task every millisecond thatgives the semaphore and accumulates a local count of the number oftimes it has been given.NOTE: Changed to every 1 second to make prints to the kernel messagelog readable.The slave process (slave.c) creates a task that blocks on the globalsemaphore 'master_sem' and accumulates a local count of the number oftimes it has been taken.NOTE: The semaphore is no longer global, instead the master andslave share it by opening it with the same key.The slave task is not attached to a timer, accomplished by passinga 0 for the 'period_nsec' argument of rtapi_task_start() and thenmanually running its first occurrence by calling rtapi_task_resume().NOTE: The slave is still not attached to a timer. I refer to thisas being "free-running". However the task_new and task_start apihas changed, you no longer call task_start for a free-running task,instead you call task_resume only.Since the slave process references a global variable, 'master_sem',declared in common.h and defined in master.c, master.o must be loadedbefore slave.o or an undefined symbol will result.NOTE: No longer true. Since both modules open the semaphore usinga key, they can be loaded in any order. The semaphore is not global,and the only thing in common.h is a #define for the key.The cumulative counts are printed to the console when the tasks aredeleted. They should be about the same, differing only by the numberof times the master task gave the semaphore before the slave task wasinitiated.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -