/[rtmk]/rtmk/thread-lock.c
ViewVC logotype

Diff of /rtmk/thread-lock.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jrydberg, Wed Jan 16 00:07:57 2002 UTC revision 1.4 by jrydberg, Wed Feb 20 20:04:42 2002 UTC
# Line 1  Line 1 
1  /*  /* Locks (sleep, pri lending, recursive).
2     Copyright 1999, 2000, 2001 Johan Rydberg, jrydberg@opencores.org.     Copyright 1999, 2000, 2001, 2002 Johan Rydberg, jrydberg@rtmk.org.
3    
4  This program is free software; you can redistribute it and/or modify  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
# Line 301  thread_lock_write_to_read (struct thread Line 301  thread_lock_write_to_read (struct thread
301    if (wakeup)    if (wakeup)
302      thread_wakeup ((int) lock);      thread_wakeup ((int) lock);
303  }  }
304    
305    /* Allow a thread that has a lock for write to acquire it
306       recursively (for read, write, or update).  */
307    void
308    thread_lock_recursive_set (struct thread_lock *lock)
309    {
310      spin_lock (&lock->interlock);
311      if (! lock->want_write)
312        {
313          panic ("lock_set_recursive: don't have write lock");
314        }
315      lock->thread = THREAD_CURRENT ();
316      spin_unlock (&lock->interlock);
317    }
318    
319    /* Prevent a lock from being re-acquired.  */
320    void
321    thread_lock_recursive_clear (struct thread_lock *lock)
322    {
323      spin_lock (&lock->interlock);
324      if (lock->thread != THREAD_CURRENT ())
325        {
326          panic ("lock_clear_recursive: wrong thread");
327        }
328    
329      if (lock->recursion_depth == 0)
330        lock->thread = (struct thread *) -1;
331      spin_unlock (&lock->interlock);
332    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26