|
@@ -19,13 +19,12 @@ typedef struct car
|
|
|
car ** active = NULL;
|
|
|
|
|
|
// all of our offset arrays
|
|
|
-int * dirs;
|
|
|
-int ** compass;
|
|
|
-int * northa;
|
|
|
-int * easta;
|
|
|
-int * southa;
|
|
|
-int * westa;
|
|
|
-int test[5] = {0,0,0,0,0};
|
|
|
+int dirs[4] = {0, 3, 6, 9};
|
|
|
+int northa[4] = {0, 0, 1, 2;
|
|
|
+int easta[4] = {2, 0, 0, 1};
|
|
|
+int southa[4] = {1, 2, 0, 0};
|
|
|
+int westa[4] = {0, 1, 2, 0};
|
|
|
+int * compass[4] = {&northa, &easta, &southa, &westa};
|
|
|
|
|
|
// car initializer/allocator
|
|
|
static car * newcar(Direction origin, Direction dest)
|
|
@@ -101,12 +100,6 @@ static void clearint(car * done)
|
|
|
static void cleanup()
|
|
|
{
|
|
|
kfree(active);
|
|
|
- kfree(northa);
|
|
|
- kfree(easta);
|
|
|
- kfree(southa);
|
|
|
- kfree(westa);
|
|
|
- kfree(compass);
|
|
|
- kfree(dirs);
|
|
|
}
|
|
|
|
|
|
// returns true if a car is turning right
|
|
@@ -130,53 +123,6 @@ void intersection_sync_init()
|
|
|
// initilaize array of active cars
|
|
|
activeinit();
|
|
|
|
|
|
- // represents offests for the dest coordinate in our array
|
|
|
- northa = kmalloc(4 * sizeof(int));
|
|
|
- *northa = 0;
|
|
|
- *(northa + 1) = 0;
|
|
|
- *(northa + 2) = 1;
|
|
|
- *(northa + 3) = 2;
|
|
|
-
|
|
|
- // represents offests for the dest coordinate in our array
|
|
|
- easta = kmalloc(4 * sizeof(int));
|
|
|
- *easta = 2;
|
|
|
- *(easta + 1) = 0;
|
|
|
- *(easta + 2) = 0;
|
|
|
- *(easta + 3) = 1;
|
|
|
-
|
|
|
- // represents offests for the dest coordinate in our array
|
|
|
- southa = kmalloc(4 * sizeof(int));
|
|
|
- *southa = 1;
|
|
|
- *(southa + 1) = 2;
|
|
|
- *(southa + 2) = 0;
|
|
|
- *(southa + 3) = 0;
|
|
|
-
|
|
|
- // represents offests for the dest coordinate in our array
|
|
|
- westa = kmalloc(4 * sizeof(int));
|
|
|
- *westa = 0;
|
|
|
- *(westa + 1) = 1;
|
|
|
- *(westa + 2) = 2;
|
|
|
- *(westa + 3) = 0;
|
|
|
-
|
|
|
- // represents offests for the origin coordinate in our array
|
|
|
- dirs = kmalloc(4 * sizeof(int));
|
|
|
- *dirs = 0;
|
|
|
- *(dirs + 1) = 3;
|
|
|
- *(dirs + 2) = 6;
|
|
|
- *(dirs + 3) = 9;
|
|
|
-
|
|
|
- // holds the 4 offests for the dest coordinate in our array
|
|
|
- compass = kmalloc(4 * sizeof(int *));
|
|
|
- *compass = northa;
|
|
|
- *(compass + 1) = easta;
|
|
|
- *(compass + 2) = southa;
|
|
|
- *(compass + 3) = westa;
|
|
|
-
|
|
|
- if ((!compass) || !(dirs) || !(northa) || !(easta) || !(southa) || !(westa))
|
|
|
- {
|
|
|
- panic("Could not allocate offset arrays.\n");
|
|
|
- }
|
|
|
-
|
|
|
//kprintf("finished init steps\n");
|
|
|
}
|
|
|
|