{"comment":{"url":"https://api.github.com/repos/granthuu/fsm_software/comments/13335920","html_url":"https://github.com/granthuu/fsm_software/commit/4ca138d8589d536b26f63e871887ea558cfc7dc1#commitcomment-13335920","id":13335920,"user":{"login":"granthuu","id":7870831,"avatar_url":"https://avatars.githubusercontent.com/u/7870831?v=3","gravatar_id":"","url":"https://api.github.com/users/granthuu","html_url":"https://github.com/granthuu","followers_url":"https://api.github.com/users/granthuu/followers","following_url":"https://api.github.com/users/granthuu/following{/other_user}","gists_url":"https://api.github.com/users/granthuu/gists{/gist_id}","starred_url":"https://api.github.com/users/granthuu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/granthuu/subscriptions","organizations_url":"https://api.github.com/users/granthuu/orgs","repos_url":"https://api.github.com/users/granthuu/repos","events_url":"https://api.github.com/users/granthuu/events{/privacy}","received_events_url":"https://api.github.com/users/granthuu/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"4ca138d8589d536b26f63e871887ea558cfc7dc1","created_at":"2015-09-21T08:02:06Z","updated_at":"2015-09-21T08:02:06Z","body":"例子11：\r\n在例10 中读队列任务具有最高优先级，所以队列不会拥有一个以上的数据单元。这是因为一旦数据被写队列任务写进队列，读队列任务立即抢占写队列任务，把刚写入的数据单元读走。在例11 中，写队列任务具有最高优先级，所以队列正常情况下一直是处于满状态。这是因为一旦读队列任务从队列中读走一个数据单元，某个写队列任务就会立即抢占读队列任务，把刚刚读走的位置重新写入，之后便又转入阻塞态以等待队列空间有效。\r\n\r\n写队列任务的实现：\r\n写队列任务指定了100 毫秒的阻塞超时时间，以便在队列满时转入阻塞态以等待队列空间有效。进入阻塞态后，一旦队列空间有效，或是等待超过了100 毫秒队列空间尚无效，其将解除阻塞。在本例中，将永远不会出现100 毫秒超时的情况，因为读队列任务在不停地从队列中读出数据从而腾出队列数据空间。\r\n\r\n读队列任务的实现：\r\n读队列任务的优先级最低，所以只有在所有写队列任务都进入阻塞态后才有机会得到执行。而写队列任务只会在队列满时才会进入阻塞态，所以读队列任务得到执行时队列已满。因此读队列任务只管不停地读取数据，不必设定超时时间。\r\n\r\n主函数main()与上一例比起来只作了微小的改动。创建的队列数可以保存三个xData 类型的数据单元，并且交换了写队列任务与读队列任务的优先级"}}