我想重新实现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,则在调用taskLock之前不会中断以下代码。
我在网上找不到解决办法。

最佳答案

v2lin Project on sourceforge.net/taskLock注释中:

 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环境中锁定调度程序

关于linux - pthread锁定/解锁解决方案,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12600787/

10-10 01:00