0

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

这是vxWorks功能的原始描述。

* 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.

我使用 pthreads 重新实现 vxWorks 任务。那么有没有可能做到这一点?

如果我理解正确。如果一个函数调用了taskLock,那么在调用taskunlock之前,下面的代码不会中断。

我在网上没有找到解决方案。

4

1 回答 1

2

来自sourceforge.net/taskLock 上的 v2lin 项目评论:

 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.

因为我们实际上无法在 pthreads 环境中锁定调度程序

于 2012-09-26T13:47:28.887 回答