Esempio n. 1
0
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);
}
Esempio n. 2
0
//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;
}