1. 26.
    0
    int allocate() {
    int i;
    wait(nfree);
    for (i=0; i < NMACHINES; i++)
    {
    wait(mutex_array[i]);
    if (available[i] != 0) {
    available[i] = 0;
    signal(mutex_array[i]);
    return i;
    } else {
    signal(mutex_array[i]);
    }
    }
    }
    release(int machine) {
    wait(mutex_array[machine]);
    available[machine] = 1;
    signal(nfree);
    signal(mutex_array[machine]);
    }
    ···
   tümünü göster