2012-09-26 167 views
0

我想重新實現vxWorks函數taskLock()和taskUnlock()。pthread鎖定/解鎖解決方案

這是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之前不會中斷以下代碼。

我在網上找不到解決方案。

+0

你爲什麼這樣做它的調度?你最終的目標是什麼? –

+0

@MaximYegorushkin'我想重新實現vxWorks函數taskLock()和taskUnlock()。 '因爲有一個vxwork相關的驅動程序(但這不是這篇文章的上下文) – Manfred

回答

2

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. 

因爲我們不能真正鎖定在並行線程環境