/[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.4 by jrydberg, Wed Feb 20 20:04:42 2002 UTC revision 1.5 by jrydberg, Wed Mar 27 00:13:45 2002 UTC
# Line 55  thread_lock_init (struct thread_lock *lo Line 55  thread_lock_init (struct thread_lock *lo
55  void  void
56  thread_lock_write (struct thread_lock *lock)  thread_lock_write (struct thread_lock *lock)
57  {  {
58      SPL_T spl = SPLOFF ();
59    
60    spin_lock (&lock->interlock);    spin_lock (&lock->interlock);
61    
62    if (lock->thread == THREAD_CURRENT ())    if (lock->thread == THREAD_CURRENT ())
63      {      {
64        lock->recursion_depth++;        lock->recursion_depth++;
65        spin_unlock (&lock->interlock);        spin_unlock (&lock->interlock);
66          SPLON (spl);
67        return;        return;
68      }      }
69    
# Line 82  thread_lock_write (struct thread_lock *l Line 85  thread_lock_write (struct thread_lock *l
85            THREAD_CURRENT()->blocked_lock = lock;            THREAD_CURRENT()->blocked_lock = lock;
86    
87            ASSERT (lock->owner != (struct thread *) -1);            ASSERT (lock->owner != (struct thread *) -1);
88    #if 0
89            if (lock->can_lend && thread_system_running)            if (lock->can_lend && thread_system_running)
90              thread_will_priority (lock->owner);              thread_will_priority (lock->owner);
91    #endif
92            thread_sleep ((int) lock, & lock->interlock, 0);            thread_sleep ((int) lock, & lock->interlock, 0);
93            THREAD_CURRENT()->blocked_lock = 0;            THREAD_CURRENT()->blocked_lock = 0;
94            spin_lock (&lock->interlock);            spin_lock (&lock->interlock);
# Line 110  thread_lock_write (struct thread_lock *l Line 114  thread_lock_write (struct thread_lock *l
114            lock->waiting = true;            lock->waiting = true;
115            THREAD_CURRENT()->blocked_lock = lock;            THREAD_CURRENT()->blocked_lock = lock;
116    
117            ASSERT (lock->owner != (struct thread *) -1);  #if 0
118            if (lock->can_lend && thread_system_running)            if (lock->can_lend && thread_system_running)
119              thread_will_priority (lock->owner);              thread_will_priority (lock->owner);
120    #endif
121            thread_sleep ((int) lock, &lock->interlock, 0);            thread_sleep ((int) lock, &lock->interlock, 0);
122            THREAD_CURRENT()->blocked_lock = 0;            THREAD_CURRENT()->blocked_lock = 0;
123            spin_lock (&lock->interlock);            spin_lock (&lock->interlock);
# Line 122  thread_lock_write (struct thread_lock *l Line 126  thread_lock_write (struct thread_lock *l
126    
127    lock->owner = THREAD_CURRENT ();    lock->owner = THREAD_CURRENT ();
128    spin_unlock (&lock->interlock);    spin_unlock (&lock->interlock);
129      SPLON (spl);
130  }  }
131    
132  /* Lock LOCK for reading.  Wait for the writer (if any) to finish before  /* Lock LOCK for reading.  Wait for the writer (if any) to finish before
# Line 174  void Line 179  void
179  thread_lock_unlock (struct thread_lock *lock)  thread_lock_unlock (struct thread_lock *lock)
180  {  {
181    bool wakeup = false;    bool wakeup = false;
182      SPL_T spl = SPLOFF ();
183    
184    spin_lock (&lock->interlock);    spin_lock (&lock->interlock);
185    
# Line 196  thread_lock_unlock (struct thread_lock * Line 202  thread_lock_unlock (struct thread_lock *
202      }      }
203    
204    spin_unlock (&lock->interlock);    spin_unlock (&lock->interlock);
205      SPLON (spl);
206    #if 0
207    if (lock->can_lend && thread_system_running    if (lock->can_lend && thread_system_running
208        && THREAD_CURRENT()->inherited_priority_p)        && THREAD_CURRENT()->inherited_priority_p)
209      thread_waive_priority (THREAD_CURRENT ());      thread_waive_priority (THREAD_CURRENT ());
210    #endif
211    if (wakeup)    if (wakeup)
212      {      {
213        thread_wakeup ((int) lock);        thread_wakeup ((int) lock);
# Line 213  thread_lock_unlock (struct thread_lock * Line 220  thread_lock_unlock (struct thread_lock *
220  bool  bool
221  thread_lock_read_to_write (struct thread_lock *lock)  thread_lock_read_to_write (struct thread_lock *lock)
222  {  {
223      SPL_T spl = SPLOFF ();
224    
225    spin_lock(&lock->interlock);    spin_lock(&lock->interlock);
226    lock->read_count--;    lock->read_count--;
227    
# Line 237  thread_lock_read_to_write (struct thread Line 246  thread_lock_read_to_write (struct thread
246        else        else
247          spin_unlock (&lock->interlock);          spin_unlock (&lock->interlock);
248    
249          SPLON (spl);
250        return true;        return true;
251      }      }
252    
# Line 267  thread_lock_read_to_write (struct thread Line 277  thread_lock_read_to_write (struct thread
277      }      }
278    
279    spin_unlock (&lock->interlock);    spin_unlock (&lock->interlock);
280      SPLON (spl);
281    return false;    return false;
282  }  }
283    

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

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