Fixing synchronization tests.

This commit is contained in:
Geoffrey Challen 2015-12-31 19:38:38 -05:00
parent 26612b6142
commit 015b989a66
4 changed files with 36 additions and 62 deletions

View File

@ -1,33 +0,0 @@
# Kernel config file using dumbvm.
# This should be used until you have your own VM system.
include conf/conf.kern # get definitions of available options
debug # Compile with debug info.
#
# Device drivers for hardware.
#
device lamebus0 # System/161 main bus
device emu* at lamebus* # Emulator passthrough filesystem
device ltrace* at lamebus* # trace161 trace control device
device ltimer* at lamebus* # Timer device
device lrandom* at lamebus* # Random device
device lhd* at lamebus* # Disk device
device lser* at lamebus* # Serial port
#device lscreen* at lamebus* # Text screen (not supported yet)
#device lnet* at lamebus* # Network interface (not supported yet)
device beep0 at ltimer* # Abstract beep handler device
device con0 at lser* # Abstract console on serial port
#device con0 at lscreen* # Abstract console on screen (not supported)
device rtclock0 at ltimer* # Abstract realtime clock
device random0 at lrandom* # Abstract randomness device
#options net # Network stack (not supported)
options semfs # Semaphores for userland
options sfs # Always use the file system
#options netfs # You might write this as a project.
options dumbvm # Chewing gum and baling wire.
#options synchprobs # Uncomment to enable ASST1 synchronization problems

View File

@ -19,9 +19,9 @@ void matchmaker(void);
* stoplight.c.
*/
void gostraight(unsigned long);
void turnleft(unsigned long);
void turnright(unsigned long);
void gostraight(uint32_t);
void turnleft(uint32_t);
void turnright(uint32_t);
void stoplight_init(void);
void stoplight_cleanup(void);

View File

@ -85,7 +85,7 @@ void stoplight_cleanup() {
}
void
turnright(unsigned long direction)
turnright(uint32_t direction)
{
(void)direction;
/*
@ -94,7 +94,7 @@ turnright(unsigned long direction)
return;
}
void
gostraight(unsigned long direction)
gostraight(uint32_t direction)
{
(void)direction;
/*
@ -103,7 +103,7 @@ gostraight(unsigned long direction)
return;
}
void
turnleft(unsigned long direction)
turnleft(uint32_t direction)
{
(void)direction;
/*

View File

@ -20,15 +20,22 @@
* Shared initialization routines
*/
static struct semaphore *testsem;
static struct semaphore *startsem;
static struct semaphore *endsem;
static
void
inititems(void)
{
if (testsem==NULL) {
testsem = sem_create("testsem", 0);
if (testsem == NULL) {
if (startsem==NULL) {
startsem = sem_create("startsem", 0);
if (startsem == NULL) {
panic("synchprobs: sem_create failed\n");
}
}
if (endsem==NULL) {
endsem = sem_create("endsem", 0);
if (endsem == NULL) {
panic("synchprobs: sem_create failed\n");
}
}
@ -45,9 +52,9 @@ male_wrapper(void * unused1, unsigned long unused2) {
(void)unused2;
random_yielder(4);
P(testsem);
P(startsem);
male();
V(testsem);
V(endsem);
return;
}
@ -69,9 +76,9 @@ female_wrapper(void * unused1, unsigned long unused2) {
(void)unused2;
random_yielder(4);
P(testsem);
P(startsem);
female();
V(testsem);
V(endsem);
return;
}
@ -93,9 +100,9 @@ matchmaker_wrapper(void * unused1, unsigned long unused2) {
(void)unused2;
random_yielder(4);
P(testsem);
P(startsem);
matchmaker();
V(testsem);
V(endsem);
return;
}
@ -147,13 +154,13 @@ whalemating(int nargs, char **args) {
for (i = 0; i < 3; i++) {
for (j = 0; j < NMATING; j++) {
V(testsem);
V(startsem);
}
}
for (i = 0; i < 3; i++) {
for (j = 0; j < NMATING; j++) {
P(testsem);
P(endsem);
}
}
@ -173,9 +180,9 @@ turnright_wrapper(void *unused, unsigned long direction)
(void)unused;
random_yielder(4);
P(testsem);
turnright(direction);
V(testsem);
P(startsem);
turnright((uint32_t)direction);
V(endsem);
return;
}
@ -186,9 +193,9 @@ gostraight_wrapper(void *unused, unsigned long direction)
(void)unused;
random_yielder(4);
P(testsem);
gostraight(direction);
V(testsem);
P(startsem);
gostraight((uint32_t)direction);
V(endsem);
return;
}
@ -199,9 +206,9 @@ turnleft_wrapper(void *unused, unsigned long direction)
(void)unused;
random_yielder(4);
P(testsem);
turnleft(direction);
V(testsem);
P(startsem);
turnleft((uint32_t)direction);
V(endsem);
return;
}
@ -255,11 +262,11 @@ int stoplight(int nargs, char **args) {
}
for (i = 0; i < NCARS; i++) {
V(testsem);
V(startsem);
}
for (i = 0; i < NCARS; i++) {
P(testsem);
P(endsem);
}
stoplight_cleanup();