Skip navigation.
Home
The QNX Community Portal

View topic - pthread_spinlock_t & intrspin_t

pthread_spinlock_t & intrspin_t

For discussion of realtime and/or embedded programming.

pthread_spinlock_t & intrspin_t

Postby rahil » Thu Oct 08, 2009 1:22 pm

Hi

Does any one know what is the significance of pthread_spinlock_t & intrspin_t (spinlock)?....or what sort of exclusion do they provide?
rahil
Active Member
 
Posts: 75
Joined: Wed Feb 11, 2009 12:13 pm
Location: India

RE: pthread_spinlock_t & intrspin_t

Postby maschoen » Thu Oct 08, 2009 3:28 pm

spinlocks are like mutex's except that they can work in interrupt handlers where no OS calls are allowed. This is necessary when you have multiple processors.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Postby Tim » Thu Oct 08, 2009 5:01 pm

Actually spinlocks (the pthread_spin_lock call) are not interrupt safe (from the doc's).

The InterruptLock call (with the intrspin_t variable) is what you want to use with multiple processors / interrupt handlers.

I recall from a few years ago using 6.3.0 that one downside to spinlocks was that they didn't trigger priority inversion processing in the kernel. What I discovered was that a high priority task that called spinlock waited infinitely spinning in a tight loop for the lock to be released by a lower priority task that never got any CPU to run. Hence, I avoid spinlock like the plague.

Tim
Tim
Senior Member
 
Posts: 1391
Joined: Wed Mar 10, 2004 12:28 am

Postby maschoen » Thu Oct 08, 2009 5:51 pm

I guess I'm confused. I wasn't thinking of a function that calls the OS like pthread_...

I thought there was some call that provided mutex like behavior at the hardware level.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Postby rahil » Fri Oct 09, 2009 6:16 am

yeah....there are sleepon locks and condvar locks......they are very suitable i guess.....but i need to evaluate them....

thanks tim & maschoen
rahil
Active Member
 
Posts: 75
Joined: Wed Feb 11, 2009 12:13 pm
Location: India


Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 1 guest