//Unit Test our Queues int main(int argc, const char *argv[]) { my_serial = Create_Serial(); queue_t my_queue = Create_Queue(my_serial); pthread_t thread_ID1,thread_ID2 ; void* exitstatus ; pthread_create(&thread_ID1 , NULL, testMtd ,(void*) my_queue ) ; pthread_create(&thread_ID2 , NULL, testMtd ,(void*) my_queue ) ; pthread_join(thread_ID2 , &exitstatus ) ; pthread_join(thread_ID1 , &exitstatus ) ; }
void Init_dp(int nphilosophers) { nphil = nphilosophers; ser = Create_Serial(); waiting_q = Create_Queue(ser); eat_crowd = Create_Crowd(ser); think_crowd = Create_Crowd(ser); // init the forks array forks = malloc(sizeof(sem_t) * nphil); int i; for(i = 0; i < nphil; i++) sem_init(&(forks[i]), 0, 1); }
//Initializes the disk scheduler void Init_ds(int ncylinders, float CylinderSeekTime) { // Instantiate the serializer, queues for requests in the upward and downward direction, and a // crowd to encapsulate active requests serializer = Create_Serial(); up_queue = Create_Queue(serializer); down_queue = Create_Queue(serializer); disk_access_crowd = Create_Crowd(serializer); //Initialize the disk's state variables cylinder_count = ncylinders; disk_access_sequence_number = 1; disk_request_sequence_number = 1; head_position = 0; }