|
@@ -29,7 +29,6 @@ typedef struct car
|
|
{
|
|
{
|
|
Direction origin;
|
|
Direction origin;
|
|
Direction dest;
|
|
Direction dest;
|
|
- bool old;
|
|
|
|
struct car * next;
|
|
struct car * next;
|
|
struct cv * cv;
|
|
struct cv * cv;
|
|
} car;
|
|
} car;
|
|
@@ -49,12 +48,11 @@ static car * newcar(Direction origin, Direction dest)
|
|
|
|
|
|
if(!(temp))
|
|
if(!(temp))
|
|
{
|
|
{
|
|
- panic("Failed to create a car.");
|
|
|
|
|
|
+ panic("Failed to create a car.\n");
|
|
}
|
|
}
|
|
|
|
|
|
temp->origin = origin;
|
|
temp->origin = origin;
|
|
temp->dest = dest;
|
|
temp->dest = dest;
|
|
- temp->old = 0;
|
|
|
|
temp->next = NULL;
|
|
temp->next = NULL;
|
|
temp->cv = NULL;
|
|
temp->cv = NULL;
|
|
|
|
|
|
@@ -68,7 +66,7 @@ static list * newlist()
|
|
|
|
|
|
if(!(temp))
|
|
if(!(temp))
|
|
{
|
|
{
|
|
- panic("Could not allocate list.");
|
|
|
|
|
|
+ panic("Could not allocate list.\n");
|
|
}
|
|
}
|
|
|
|
|
|
temp->front = NULL;
|
|
temp->front = NULL;
|
|
@@ -94,7 +92,6 @@ static void push(car * newcar)
|
|
// called when a car clears the intersection
|
|
// called when a car clears the intersection
|
|
static void clearint(car * done)
|
|
static void clearint(car * done)
|
|
{
|
|
{
|
|
- kprintf("vehicle cleared");
|
|
|
|
car * temp = active->front;
|
|
car * temp = active->front;
|
|
car * temp2 = NULL;
|
|
car * temp2 = NULL;
|
|
|
|
|
|
@@ -167,7 +164,7 @@ void intersection_sync_init()
|
|
|
|
|
|
if (!(globlock))
|
|
if (!(globlock))
|
|
{
|
|
{
|
|
- panic("Failed to create lock!");
|
|
|
|
|
|
+ panic("Failed to create lock!\n");
|
|
}
|
|
}
|
|
|
|
|
|
active = newlist();
|
|
active = newlist();
|
|
@@ -229,8 +226,6 @@ void intersection_before_entry(Direction origin, Direction destination)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- new->old = 1; // make new "old", since now it has already waited once
|
|
|
|
-
|
|
|
|
// create cv for temp if it doesn't have one yet
|
|
// create cv for temp if it doesn't have one yet
|
|
if(!(temp->cv))
|
|
if(!(temp->cv))
|
|
{
|
|
{
|