Browse Source

removed queues since they aren't really used

tarfeef101 7 năm trước cách đây
mục cha
commit
fdb50de1bf
2 tập tin đã thay đổi với 3 bổ sung46 xóa
  1. 1 46
      kern/synchprobs/traffic_synch.c
  2. 2 0
      kern/thread/synch.c

+ 1 - 46
kern/synchprobs/traffic_synch.c

@@ -40,7 +40,6 @@ typedef struct list
   car * back;
 } list;
 
-list * queue = NULL;
 list * active = NULL;
 
 // car initializer/allocator
@@ -78,28 +77,6 @@ static list * newlist()
   return temp;
 }
 
-// puts a car into the queue, at the front if old is true, the back otherwise
-static void enqueue(car * newcar)
-{
-  if (!(queue->back))
-  {
-    queue->front = newcar;
-    queue->back = newcar;
-  }
-  
-  if (newcar->old) // if the car is "old", let it go first. be nice to your elders
-  {
-    car * temp = queue->front;
-    queue->front = newcar;
-    newcar->next = temp;
-    
-    return;
-  }
-  
-  queue->back->next = newcar;
-  queue->back = newcar;
-}
-
 // push a car to the end of the active list
 static void push(car * newcar)
 {
@@ -113,24 +90,6 @@ static void push(car * newcar)
   active->back = newcar;
 }
 
-// remove an element from the front of the queue
-static car * pop()
-{
-  if (!(queue->front))
-  {
-    return NULL;
-  }
-  
-  if (queue->front == queue->back)
-  {
-    queue->back == NULL;
-  }
-  
-  car * temp = queue->front;
-  queue->front = queue->front->next;
-  return temp;
-}
-
 // called when a car clears the intersection
 static void clearint(car * done)
 {
@@ -140,7 +99,7 @@ static void clearint(car * done)
   while(temp != done)
   {
     temp2 = temp;
-    temp = temp>next;
+    temp = temp->next;
   }
   
   // first element of the list is being removed
@@ -201,7 +160,6 @@ void intersection_sync_init()
     panic("Failed to create lock!");
   }
   
-  queue = newlist();
   active = newlist();
 }
 
@@ -214,10 +172,8 @@ void intersection_sync_init()
  */
 void intersection_sync_cleanup()
 {
-  KASSERT(queue);
   KASSERT(active);
   
-  dellist(queue);
   dellist(active);
   lock_destroy(globlock);
 }
@@ -263,7 +219,6 @@ void intersection_before_entry(Direction origin, Direction destination)
       }
       else
       {
-        enqueue(new);
         new->old = 1; // make new "old", since now it has already waited once
         lock_release(globlock);
         

+ 2 - 0
kern/thread/synch.c

@@ -274,6 +274,7 @@ void
 cv_signal(struct cv * cv, struct lock * lock)
 {
   KASSERT(lock_do_i_hold(lock));
+  KASSERT(cv);
   
   wchan_wakeone(cv->wc);
 }
@@ -282,6 +283,7 @@ void
 cv_broadcast(struct cv * cv, struct lock * lock)
 {
 	KASSERT(lock_do_i_hold(lock));
+	KASSERT(cv);
 	
 	wchan_wakeall(cv->wc);
 }