2022-04-06 06:45:57 +00:00
|
|
|
/*
|
|
|
|
+-------------+---------+-----------------------+
|
|
|
|
| John Breaux | jab0910 | JohnBreaux@my.unt.edu |
|
|
|
|
+-------------+---------+-----------------------+
|
|
|
|
| 2022-04-04 |
|
|
|
|
+-----------------------------------------------+
|
|
|
|
*/
|
2022-04-04 18:39:30 +00:00
|
|
|
#define N 8
|
2022-04-06 03:30:46 +00:00
|
|
|
#define timescale 10000
|
2022-04-05 20:37:42 +00:00
|
|
|
|
|
|
|
//function defines, renaming wait and signal
|
|
|
|
#define wait(x) sem_wait(&x)
|
|
|
|
#define signal(x) sem_post(&x)
|
|
|
|
|
2022-04-06 03:30:46 +00:00
|
|
|
// renaming link and unlink to match pseudocode semantics
|
|
|
|
#define link(x,y) list_link(y,x)
|
|
|
|
#define unlink(x) list_unlink(x)
|
|
|
|
|
2022-04-04 18:39:30 +00:00
|
|
|
// Shared memory through global variables
|
|
|
|
// Create all of memory
|
|
|
|
extern block memory[N];
|
|
|
|
// create the three lists
|
2022-04-05 01:12:40 +00:00
|
|
|
extern list *freelist, *list1, *list2;
|
|
|
|
|
|
|
|
// count semaphores
|
2022-04-06 04:15:51 +00:00
|
|
|
extern sem_t sem_freelist, sem_list1, sem_list2, sem_freelist_minus_1;
|
2022-04-05 01:12:40 +00:00
|
|
|
// binary semaphores
|
2022-04-06 03:30:46 +00:00
|
|
|
extern sem_t mut_freelist, mut_list1, mut_list2;
|