简体   繁体   中英

pthread lock / unlock solution

I want to reimplement the vxWorks functions taskLock() and taskUnlock().

Here is the original description of the vxWorks function.

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

I use pthreads to reimplement the vxWorks tasks. So is there a possibility to do that?

If I understand right. If a function call taskLock, there will be no interruption of the following code until taskunlock is called.

I didn't find a solution in the web.

From the v2lin Project on sourceforge.net/ taskLock comments:

 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.

Because we cannot actually lock the scheduler in a pthreads environment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM