What task is supposed to be created in this example?

> For an ordinary binary semaphore, a > task attempting to synchronize to an > external event creates an empty > semaphore....A second task which > controls the synchronization event > gives the semaphore when it is no > longer needed. #include "vxWorks.h" #include "semLib.h" #define T_PRIORITY 50 SEM_ID syncExampleSem; // named semaphore object void initialize (void) { // set up FIFO queue with emtpy binary semaphore syncSem = semBCreate (SEM_Q_FIFO, SEM_EMPTY); // create task1 taskSpawn ("task1", T_PRIORITY, 0, 10000, task1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // create task2 taskSpawn ("task2", T_PRIORITY, 0, 10000, task2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } void task1 (void) { // stay here until semaphore becomes available semTake (syncExampleSem, WAIT_FOREVER); // do something } void task2 (void) { // do something // now let task1 execute semGive (synExampleSem); } My question is why don't I see the first task creating the empty semaphore, as described? (It looks like it is just done "generically" in the main function?) **"a task attempting to synchronize to an external event creates an empty semaphore".** Also, I don't really see how the second task is "controlling" the synchronization? Thank you. See: Example of synchronization through binary semaphore http://www.cross-comp.com/instr/pages/embedded/VxWorksTutorial.aspx#VxWorks%20Programming

以上就是What task is supposed to be created in this example?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏