There are 3 choices.
1. I'm going to put pthread_mutex out in a few days.
2.  On a uniprocessor you should use Jery Epplin's semaphore package right 
   now.
3.  Or you can do things the correct way and define synchronization for
   your specific tasks using suspend and test_and_set.
   For example, suppose thread X and Y share buffer  B and want to 
   have exclusive use of it for non-smp 

pthread_t waiter, buffer_user;
access_lock(){
  unsigned int s;
    rtl_no_interrupts(s)
    if(buffer_user && (buffer_user != pthread_self()){
              waiter = pthread_self();
              pthread_suspend_np(waiter);
              }
    buffer_user = pthread_self();
    rtl_restore_interrupts(s);
    }

free_lock()
  unsigned int s;
  rtl_no_interrupts(s);
  buffer_user = 0;
  if(waiter && (waiter != pthread_self()))pthread_wakeup(waiter);
  rtl_restore_interrupts(s);
  return;

}

Should work. If you want SMP you need to do some spinlocks too.
I'm working on making this easier, but it is not so hard.

                
        
          waiting[
spinlock_t lock;
access_buffer(){
unsigned int pstate;
rtl_spin_lock_irqsave(&lock,state);
while(1){
     if(in_use){
          waiter = pthread_self();
          rtl_spin_unlock_irqrestore(buffersynclock,state);
          rtl_suspend(waiter);

          }
in_use = 1;

    
if(test_and_set_bit(0,&otherowns))
     pthread_suspend_np(pthread_self())


Get_other_to_wait:
test_and_set

On Thu, Jan 20, 2000 at 11:15:08PM -0200, Anderson Borges wrote:
> HELP !!!!  
>   
> I need to know if there is any way to use semaphores to block REAL-TIME tasks in 
>RT-Linux.(not RTAI)  
> I need to communicate two REAL-TIME tasks with blockade !!!!  
> How can I do it using RT-Linux ?!?!?  
>   
> Thanks !!!

-- 
---------------------------------------------------------
Victor Yodaiken 
FSMLabs:  www.fsmlabs.com  www.rtlinux.com
FSMLabs is a servicemark and a service of 
VJY Associates L.L.C, New Mexico.

--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to