首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >线程锁定/解锁解决方案

线程锁定/解锁解决方案
EN

Stack Overflow用户
提问于 2012-09-26 11:33:35
回答 1查看 731关注 0票数 0

我想重新实现vxWorks函数taskLock()和taskUnlock()。

下面是vxWorks函数的原始描述。

代码语言:javascript
复制
* taskUnlock - enable task rescheduling
*
* This routine decrements the preemption lock count.  Typically this call is
* paired with taskLock() and concludes a critical section of code.
* Preemption will not be unlocked until taskUnlock() has been called as many
* times as taskLock().  When the lock count is decremented to zero, any tasks
* that were eligible to preempt the current task will execute.
*
* The taskUnlock() routine is not callable from interrupt service routines.

我使用线程来重新实现vxWorks任务。那么,有可能做到这一点吗?

如果我明白的话。如果函数调用taskLock,则在调用任务释放之前不会中断以下代码。

我在网上找不到解决办法。

EN

回答 1

Stack Overflow用户

发布于 2012-09-26 13:47:28

来自基于SourceForm.net// v2lin项目 taskLock注释:

代码语言:javascript
复制
 taskLock - 'locks the scheduler' to prevent preemption of the current task
           by other task-level code.  Because we cannot actually lock the
           scheduler in a pthreads environment, we temporarily set the
           dynamic priority of the calling thread above that of any other
           thread, thus guaranteeing that no other tasks preempt it.

,因为我们实际上不能将调度程序锁定在p线程环境中。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12600787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档