#include<stdio.h> #include<ctype.h> #include <semaphore.h> #include <sys/types.h> #include <pthread.h> #include <unistd.h> const int user; const int COUNTER = 5; //Number of I/O requests per each int TOTAL = 25; int DRIVERS = 2; int USERS = 5; //Total number of I/O requests //Total number of Drivers //Number of Users //Semaphores for User sem_t fullUser; sem_t ioReq; //binarysem mutexUser; //User buffer at max sem_t mutexUser; sem_init(&mutexUser, 0, 1); /* initialize mutex to 1 - binary semaphore */ //User buffer at empty //User buffer protect //Semaphores for Driver 1 sem_t fullDriver1[DRIVERS]; sem_t reqPend[DRIVERS]; //binarysem mutexDriver1[DRIVERS]; //Driver 1 buffer at max sem_t mutexDriver; /* Create the mutexDriver semaphore and initialize to DRIVERS buffer size */ sem_init(&mutexDriver, 0, DRIVERS); //Driver 1 buffer at empty //Driver 1 buffer protect //Semaphores for Driver 2 sem_t fullDriver2[DRIVERS]; sem_t reqPend2[DRIVERS]; //binarysem mutexDriver2[DRIVERS]; //Driver 2 buffer at max sem_t mutexDriver2; sem_init(&mutexDriver2, 0, DRIVERS); //Driver 2 buffer at empty //Driver 2 protect //Semaphores for Disk 1 sem_t fullDisk1[DRIVERS]; sem_t physicalio1[DRIVERS]; //binarysem mutexDisk1[DRIVERS]; //Disk buffer at max sem_t mutexDisk1; sem_init(&mutexDisk1, 0, DRIVERS); //Disk buffer at empty //Disk buffer protect //Semaphores for Disk 2 sem_t physicalio2[DRIVERS]; sem_t fullDisk2[DRIVERS]; //binarysem mutexDisk2[DRIVERS]; //Disk buffer at empty sem_t mutexDisk2; sem_init(&mutexDisk2, 0, DRIVERS); //Disk buffer at max //Disk buffer protect //Other semaphores //binarysem reqService[USERS]; sem_t reqService; sem_init(&reqService, 0, USERS); //binarysem operationComplete[DRIVERS]; sem_t operationComplete; sem_init(&operationComplete, 0, DRIVERS); //binarysem opComplete2[DRIVERS]; sem_t opComplete2; sem_init(&opComplete2, 0, DRIVERS); //binarysem print; //I/O request protect sem_t print; sem_init(&print, 0, 1); //Disk protection //Disk 2 protection //Print protection //globals int idUser; int addrUser; int devUser; int idIorq[DRIVERS]; int addrIorq[DRIVERS]; int pio[DRIVERS]; int countdriver = 0; int countdisk = 0; //User/Doio id buffer //User/Doio address buffer //User/Doio device buffer //Doio/Driver user id buffer //Doio/Driver address id buffer //Driver/Disk //Counter for Driver //Counter for Disk void User(int id) { int i, addr, dev; //Local variables used for(i = 0; i < COUNTER; i++) { //Loop through the number of requests addr = random(200) + 1; //Generating random I/O information dev = random(2); //Generating random Driver assignment p(fullUser); //Decrement available buffer locations between User and DOIO p(mutexUser); //Exclusive access to I/O request idUser = id; //Passing user id to shared resource addrUser = addr; //Passing address to shared resource devUser = dev; //Passing driver id to shared resource p(print); //Gaining control of the printer cout << "User " << id << " executes system call SIO or DOIO" << endl; v(print); v(mutexUser); //Released control of the printer //Release editting control of the I/O v(ioReq); //Inform DOIO that the request is p(reqService[id]); //Wait for completion of I/O request pending operation. } } void Doio(){ int j, idIorb, addrIorb, devIorb; for( j = 0; j < TOTAL; j++) through the total requests { p(ioReq); sent a request p(mutexUser); request idIorb = idUser; addrIorb = addrUser; devIorb = devUser; v(mutexUser); I/O request v(fullUser); buffer locations between User and DOIO // //Local variables used //For loop that goes //Checking to see if user //Exclusive access to I/O //Copying user ID into DOIO //Copying address into DOIO //Copying driver ID into DOIO //Releasing editting control of //Incrementing available Ending consuming process p(fullDriver1[devIorb]); //Decrementing available buffer locations p(mutexDriver1[devIorb]); //Exclusive access to I/O request idIorq[devIorb] = idIorb; //Passing user to shared source addrIorq[devIorb] = addrIorb; //Passing address information to shared resource v(mutexDriver1[devIorb]); //Releasing editting control of I/O request v(reqPend[devIorb]); //Inform Driver request is pending p(print); //Gain control of printer cout << "DOIO assembles IORB and inserts it into IORQ for User " << idIorb << endl; v(print); //Release control of printer // Begin consuming process p(ioReq); request p(mutexUser); request idIorb = idUser; addrIorb = addrUser; devIorb = devUser; //Checking to see if user sent a //Exclusive access to I/O //Copying user into DOIO //Copying address into DOIO //Copying driver ID into DOIO request v(mutexUser); //Releasing control of I/O v(fullUser); //Incrementing available buffer locations //Begin producing process p(fullDriver2[devIorb]); //Decrementing available buffer location p(mutexDriver2[devIorb]); //Exclusive access to I/O request idIorq[devIorb] = idIorb; //Passing user into shared source addrIorq[devIorb] = addrIorb; //Passing addr into shared source cout << "DOIO assembles IORB and inserts it in IORQ2 for User " << idIorb << endl; v(mutexDriver2[devIorb]); //Releasing control of I/O request v(reqPend2[devIorb]); //Inform driver request is pending } } void Driver1( int id ){ int idDriver, addrDriver, k; //Local variables p(reqPend[id]); //Check to see if there is a request from DOIO while(countdriver < 25){ //Loop through the requests if ( countdriver == 25 ) { //Check for out of bounds v(reqPend2[k]); break; } p(mutexDriver1[id]); //Gain exclusive editting access to IORQ idDriver = idIorq[id]; //Copy user ID into Driver addrDriver = addrIorq[id]; //Copy address into Driver v(mutexDriver1[id]); //Release editting control of I/O request v(fullDriver1[id]); //Increment available buffer location by 1 p(print); //Control of printer cout << "Driver 1 initiates I/O operation for user " << idDriver << endl; v(print); //Release control of printer p(fullDisk1[id]); //Decrement available buffer locations p(mutexDisk1[id]); //Gain access to Disk request pio[id] = addrDriver; //Pass adress to shared resource p(print); cout << "Driver 1 signals User " << idDriver << "that the operation is complete." << endl; countdriver++; v(print); v(mutexDisk1[id]); //Release control of Disk request v(physicalio1[id]); //Inform disk request is pending p(operationComplete[id]); //Waiting for disk operation to complete v(reqService[idDriver]); //Inform user request is complete } if ( countdriver == 25 ) { v(reqPend[k]); break; } //Check for out of bounds } void Driver2( int id ){ int idDriver2, addrDriver2, i = 0; //Local variables p(reqPend2[id]); //Check to see if there is a request from DOIO while( countdriver < 25 ){ //Loop through the requests if( countdriver == 25 ){ //Check for out of bounds v(reqPend[i]); break; } p(mutexDriver2[id]); //Gain exclusive access to I/O request idDriver2 = idIorq[id]; //Copy user ID into Driver addrDriver2 = addrIorq[id]; //Copy address into Driver v(mutexDriver2[id]); //Release control of Disk Request v(fullDriver2[id]); //Increment available buffer location p(print); //Access printer cout << "Driver 2 initiates I/O operation for user " << idDriver2 << endl; v(print); //Release access to printer p(fullDisk2[id]); //Decerement available buffer locations p(mutexDisk2[id]); //Gain access to Disk 2 request pio[id] = addrDriver2; //Pass address to a shared resource p(print); cout << "Driver 2 signals User " << idDriver2 << "that the operation is complete." << endl; countdriver++; v(print); v(mutexDisk2[id]); //Release control of disk request v(physicalio2[id]); //Inform disk 2 request is pending p(opComplete2[id]); //Waiting for disk 2 to complete v(reqService[idDriver2]); //Inform user the request is complete if( countdriver == 25 ){ bounds v(reqPend[i]); break; } } } void Disk1( int id ){ int i, seek; //Check for out of while(countdisk < 25){ p(physicalio1[id]); //Decrement available buffer locations p(mutexDisk1[id]); //Gain exclusive access to I/O request seek = pio[id]; //Grabbing the address from shared resource v(mutexDisk1[id]); //Releasing control of Disk 1 v(fullDisk1[id]); //Increment available buffer location for(i = 1; i < seek; i++){ } //Dummy loop that iterates from i to seek p(print); //Gain access to the printer cout << "Disk 1 Completes I/O operation." << endl; v(print); //Release acess to the printer. countdisk++; v(operationComplete1[id]); //Inform Driver operation is complete } } void Disk2( int id ){ int i, seek; //Local variables while(countdisk < 25){ //Loop through the requests p(physicalio2[id]); //Decrement available buffer locations p(mutexDisk2[id]); //Gain exclusive access to I/O request seek = pio[id]; //Grabbing the address from shared resources v(mutexDisk2[id]); //Releasing control of Disk 2 v(fullDisk2[id]); //Increment available buffer location for(i = 1; i < seek; i++){} //Dummy loop that iterates from i to seek cout << "Disk 2 Completes I/O operation." << endl; countdisk++; v(opComplete2[id]); //Inform Driver operation is complete } } main(){ int z = 0; initialsem(fullUser, 1); initialsem(ioReq, 0); initialsem(mutexUser, 1); for( z = 0; z < USERS; z++ ){ initialsem(reqService[z], 0); } for( z = 0; z < DRIVERS; z++){ initialsem(fullDriver1[z], 1); initialsem(reqPend[z],0); initialsem(mutexDriver1[z], 1); initialsem(fullDriver2[z], 1); initialsem(reqPend2[z], 0); initialsem(mutexDriver1[z], 1); initialsem(fullDisk1[z], 1); initialsem(physicalio1[z], 0); initialsem(mutexDisk1[z], 1); initialsem(fullDisk2[z], 1); initialsem(physicalio2[z], 0); initialsem(mutexDisk2[z], 1); initialsem(operationComplete[z], 0); initialsem(opComplete2[z], 0); } initialsem(print, 1); cobegin{ User(0); User(1); User(2); User(3); User(4); Doio(); Driver1(0); Driver2(0); Disk1(0); Disk2(0); } }
Standard input is empty
prog.c:19:14: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&mutexUser, 0, 1); /* initialize mutex to 1 - binary semaphore */
^
prog.c:19:26: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&mutexUser, 0, 1); /* initialize mutex to 1 - binary semaphore */
^
prog.c:19:29: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&mutexUser, 0, 1); /* initialize mutex to 1 - binary semaphore */
^
prog.c:23:7: error: variably modified ‘fullDriver1’ at file scope
sem_t fullDriver1[DRIVERS];
^~~~~~~~~~~
prog.c:24:7: error: variably modified ‘reqPend’ at file scope
sem_t reqPend[DRIVERS];
^~~~~~~
prog.c:28:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&mutexDriver, 0, DRIVERS);
^
prog.c:28:27: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&mutexDriver, 0, DRIVERS);
^
prog.c:28:30: error: expected declaration specifiers or ‘...’ before ‘DRIVERS’
sem_init(&mutexDriver, 0, DRIVERS);
^~~~~~~
prog.c:32:7: error: variably modified ‘fullDriver2’ at file scope
sem_t fullDriver2[DRIVERS];
^~~~~~~~~~~
prog.c:33:7: error: variably modified ‘reqPend2’ at file scope
sem_t reqPend2[DRIVERS];
^~~~~~~~
prog.c:36:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&mutexDriver2, 0, DRIVERS);
^
prog.c:36:28: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&mutexDriver2, 0, DRIVERS);
^
prog.c:36:31: error: expected declaration specifiers or ‘...’ before ‘DRIVERS’
sem_init(&mutexDriver2, 0, DRIVERS);
^~~~~~~
prog.c:40:7: error: variably modified ‘fullDisk1’ at file scope
sem_t fullDisk1[DRIVERS];
^~~~~~~~~
prog.c:41:7: error: variably modified ‘physicalio1’ at file scope
sem_t physicalio1[DRIVERS];
^~~~~~~~~~~
prog.c:44:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&mutexDisk1, 0, DRIVERS);
^
prog.c:44:26: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&mutexDisk1, 0, DRIVERS);
^
prog.c:44:29: error: expected declaration specifiers or ‘...’ before ‘DRIVERS’
sem_init(&mutexDisk1, 0, DRIVERS);
^~~~~~~
prog.c:48:7: error: variably modified ‘physicalio2’ at file scope
sem_t physicalio2[DRIVERS];
^~~~~~~~~~~
prog.c:49:7: error: variably modified ‘fullDisk2’ at file scope
sem_t fullDisk2[DRIVERS];
^~~~~~~~~
prog.c:52:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&mutexDisk2, 0, DRIVERS);
^
prog.c:52:26: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&mutexDisk2, 0, DRIVERS);
^
prog.c:52:29: error: expected declaration specifiers or ‘...’ before ‘DRIVERS’
sem_init(&mutexDisk2, 0, DRIVERS);
^~~~~~~
prog.c:58:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&reqService, 0, USERS);
^
prog.c:58:26: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&reqService, 0, USERS);
^
prog.c:58:29: error: expected declaration specifiers or ‘...’ before ‘USERS’
sem_init(&reqService, 0, USERS);
^~~~~
prog.c:62:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&operationComplete, 0, DRIVERS);
^
prog.c:62:33: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&operationComplete, 0, DRIVERS);
^
prog.c:62:36: error: expected declaration specifiers or ‘...’ before ‘DRIVERS’
sem_init(&operationComplete, 0, DRIVERS);
^~~~~~~
prog.c:66:13: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&opComplete2, 0, DRIVERS);
^
prog.c:66:27: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&opComplete2, 0, DRIVERS);
^
prog.c:66:30: error: expected declaration specifiers or ‘...’ before ‘DRIVERS’
sem_init(&opComplete2, 0, DRIVERS);
^~~~~~~
prog.c:71:14: error: expected declaration specifiers or ‘...’ before ‘&’ token
sem_init(&print, 0, 1);
^
prog.c:71:22: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&print, 0, 1);
^
prog.c:71:25: error: expected declaration specifiers or ‘...’ before numeric constant
sem_init(&print, 0, 1);
^
prog.c:79:5: error: variably modified ‘idIorq’ at file scope
int idIorq[DRIVERS];
^~~~~~
prog.c:80:5: error: variably modified ‘addrIorq’ at file scope
int addrIorq[DRIVERS];
^~~~~~~~
prog.c:81:5: error: variably modified ‘pio’ at file scope
int pio[DRIVERS];
^~~
prog.c:92:1: error: expected identifier or ‘(’ before ‘{’ token
{
^
prog.c:116:3: error: expected identifier or ‘(’ before ‘}’ token
} } void Doio(){
^
prog.c: In function ‘Doio’:
prog.c:118:16: error: ‘lt’ undeclared (first use in this function)
for( j = 0; j < TOTAL; j++)
^~
prog.c:118:16: note: each undeclared identifier is reported only once for each function it appears in
prog.c:118:20: error: ‘TOTAL’ undeclared (first use in this function)
for( j = 0; j < TOTAL; j++)
^~~~~
prog.c:118:25: error: expected ‘)’ before ‘;’ token
for( j = 0; j < TOTAL; j++)
^
prog.c:119:1: error: ‘through’ undeclared (first use in this function)
through the total requests
^~~~~~~
prog.c:119:9: error: expected ‘;’ before ‘the’
through the total requests
^~~
prog.c:117:26: warning: unused variable ‘devIorb’ [-Wunused-variable]
int j, idIorb, addrIorb, devIorb;
^~~~~~~
prog.c:117:16: warning: unused variable ‘addrIorb’ [-Wunused-variable]
int j, idIorb, addrIorb, devIorb;
^~~~~~~~
prog.c:117:8: warning: unused variable ‘idIorb’ [-Wunused-variable]
int j, idIorb, addrIorb, devIorb;
^~~~~~
prog.c: In function ‘Driver1’:
prog.c:204:1: warning: implicit declaration of function ‘p’ [-Wimplicit-function-declaration]
p(reqPend[id]);
^
prog.c:206:1: error: unknown type name ‘is’
is a request from DOIO
^~
prog.c:206:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘request’
is a request from DOIO
^~~~~~~
prog.c:207:24: warning: statement with no effect [-Wunused-value]
while(countdriver < 25){
^~
prog.c:207:26: error: expected ‘;’ before ‘)’ token
while(countdriver < 25){
^
prog.c:207:26: error: expected statement before ‘)’ token
prog.c:209:1: error: ‘requests’ undeclared (first use in this function)
requests
^~~~~~~~
prog.c:210:1: error: expected ‘;’ before ‘if’
if ( countdriver == 25 ) {
^~
prog.c:218:1: warning: statement with no effect [-Wunused-value]
access to IORQ
^~~~~~
prog.c:218:8: error: expected ‘;’ before ‘to’
access to IORQ
^~
prog.c:223:1: warning: implicit declaration of function ‘v’ [-Wimplicit-function-declaration]
v(mutexDriver1[id]);
^
prog.c:223:3: error: ‘mutexDriver1’ undeclared (first use in this function)
v(mutexDriver1[id]);
^~~~~~~~~~~~
prog.c:225:1: error: unknown type name ‘of’
of I/O request
^~
prog.c:225:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘/’ token
of I/O request
^
prog.c:228:1: error: unknown type name ‘location’
location by 1
^~~~~~~~
prog.c:228:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
location by 1
^
prog.c:231:1: error: ‘cout’ undeclared (first use in this function)
cout << "Driver 1 initiates I/O operation for user " << idDriver <<
^~~~
prog.c:231:7: error: ‘lt’ undeclared (first use in this function)
cout << "Driver 1 initiates I/O operation for user " << idDriver <<
^~
prog.c:231:16: error: ‘quot’ undeclared (first use in this function)
cout << "Driver 1 initiates I/O operation for user " << idDriver <<
^~~~
prog.c:231:21: error: ‘Driver’ undeclared (first use in this function)
cout << "Driver 1 initiates I/O operation for user " << idDriver <<
^~~~~~
prog.c:231:28: error: expected ‘;’ before numeric constant
cout << "Driver 1 initiates I/O operation for user " << idDriver <<
^
prog.c:232:1: error: ‘endl’ undeclared (first use in this function)
endl;
^~~~
prog.c:237:1: error: unknown type name ‘buffer’
buffer locations
^~~~~~
prog.c:238:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘p’
p(mutexDisk1[id]);
^
prog.c:240:1: error: unknown type name ‘request’
request
^~~~~~~
prog.c:241:1: error: variable-sized object may not be initialized
pio[id] = addrDriver;
^~~
prog.c:243:1: error: unknown type name ‘resource’
resource
^~~~~~~~
prog.c:244:1: warning: parameter names (without types) in function declaration
p(print);
^
prog.c:245:28: error: expected ‘;’ before numeric constant
cout << "Driver 1 signals User " << idDriver << "that the operation
^
prog.c:245:83: error: unknown type name ‘that’
cout << "Driver 1 signals User " << idDriver << "that the operation
^~~~
prog.c:245:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘operation’
cout << "Driver 1 signals User " << idDriver << "that the operation
^~~~~~~~~
prog.c:249:13: error: subscripted value is neither array nor pointer nor vector
v(mutexDisk1[id]);
^
prog.c:251:1: error: unknown type name ‘request’
request
^~~~~~~
prog.c:252:3: error: expected declaration specifiers or ‘...’ before ‘physicalio1’
v(physicalio1[id]);
^~~~~~~~~~~
prog.c:254:1: error: unknown type name ‘pending’
pending
^~~~~~~
prog.c:255:3: error: expected declaration specifiers or ‘...’ before ‘operationComplete’
p(operationComplete[id]);
^~~~~~~~~~~~~~~~~
prog.c:257:1: error: unknown type name ‘to’
to complete
^~
prog.c:258:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘v’
v(reqService[idDriver]);
^
prog.c:261:1: error: break statement not within loop or switch
break;
^~~~~
prog.c:241:1: warning: unused variable ‘pio’ [-Wunused-variable]
pio[id] = addrDriver;
^~~
prog.c: In function ‘Driver2’:
prog.c:268:1: error: unknown type name ‘is’
is a request from DOIO
^~
prog.c:268:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘request’
is a request from DOIO
^~~~~~~
prog.c:269:25: warning: statement with no effect [-Wunused-value]
while( countdriver < 25 ){
^~
prog.c:269:28: error: expected ‘;’ before ‘)’ token
while( countdriver < 25 ){
^
prog.c:269:28: error: expected statement before ‘)’ token
prog.c:272:1: error: expected ‘;’ before ‘if’
if( countdriver == 25 ){
^~
prog.c:280:1: error: ‘I’ undeclared (first use in this function)
I/O request
^
prog.c:280:3: error: ‘O’ undeclared (first use in this function)
I/O request
^
prog.c:280:5: error: expected ‘;’ before ‘request’
I/O request
^~~~~~~
prog.c:285:15: error: subscripted value is neither array nor pointer nor vector
v(mutexDriver2[id]);
^
prog.c:287:1: error: unknown type name ‘Request’
Request
^~~~~~~
prog.c:288:3: error: expected declaration specifiers or ‘...’ before ‘fullDriver2’
v(fullDriver2[id]);
^~~~~~~~~~~
prog.c:290:1: error: unknown type name ‘location’
location
^~~~~~~~
prog.c:291:1: warning: parameter names (without types) in function declaration
p(print);
^
prog.c:293:28: error: expected ‘;’ before numeric constant
cout << "Driver 2 initiates I/O operation for user " << idDriver2 <<
^
prog.c:299:1: error: unknown type name ‘buffer’
buffer locations
^~~~~~
prog.c:300:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘p’
p(mutexDisk2[id]);
^
prog.c:302:1: error: unknown type name ‘request’
request
^~~~~~~
prog.c:303:1: error: variable-sized object may not be initialized
pio[id] = addrDriver2;
^~~
prog.c:305:1: error: unknown type name ‘resource’
resource
^~~~~~~~
prog.c:306:1: warning: parameter names (without types) in function declaration
p(print);
^
prog.c:307:28: error: expected ‘;’ before numeric constant
cout << "Driver 2 signals User " << idDriver2 << "that the operation
^
prog.c:307:84: error: unknown type name ‘that’
cout << "Driver 2 signals User " << idDriver2 << "that the operation
^~~~
prog.c:307:93: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘operation’
cout << "Driver 2 signals User " << idDriver2 << "that the operation
^~~~~~~~~
prog.c:311:13: error: subscripted value is neither array nor pointer nor vector
v(mutexDisk2[id]);
^
prog.c:313:1: error: unknown type name ‘request’
request
^~~~~~~
prog.c:314:3: error: expected declaration specifiers or ‘...’ before ‘physicalio2’
v(physicalio2[id]);
^~~~~~~~~~~
prog.c:316:1: error: unknown type name ‘pending’
pending
^~~~~~~
prog.c:317:3: error: expected declaration specifiers or ‘...’ before ‘opComplete2’
p(opComplete2[id]);
^~~~~~~~~~~
prog.c:319:1: error: unknown type name ‘complete’
complete
^~~~~~~~
prog.c:320:3: error: expected declaration specifiers or ‘...’ before ‘reqService’
v(reqService[idDriver2]);
^~~~~~~~~~
prog.c:322:1: error: ‘complete’ undeclared (first use in this function)
complete
^~~~~~~~
prog.c:323:1: error: expected ‘;’ before ‘if’
if( countdriver == 25 ){ bounds v(reqPend[i]);
^~
prog.c:303:1: warning: unused variable ‘pio’ [-Wunused-variable]
pio[id] = addrDriver2;
^~~
prog.c:264:29: warning: unused variable ‘i’ [-Wunused-variable]
int idDriver2, addrDriver2, i = 0;
^
prog.c: In function ‘Disk1’:
prog.c:330:1: error: unknown type name ‘locations’
locations
^~~~~~~~~
prog.c:331:3: error: expected declaration specifiers or ‘...’ before ‘mutexDisk1’
p(mutexDisk1[id]);
^~~~~~~~~~
prog.c:333:1: error: ‘I’ undeclared (first use in this function)
I/O request
^
prog.c:333:3: error: ‘O’ undeclared (first use in this function)
I/O request
^
prog.c:333:5: error: expected ‘;’ before ‘request’
I/O request
^~~~~~~
prog.c:336:1: error: unknown type name ‘shared’
shared resource
^~~~~~
prog.c:337:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘v’
v(mutexDisk1[id]);
^
prog.c:339:1: warning: statement with no effect [-Wunused-value]
1
^
prog.c:340:1: error: expected ‘;’ before ‘v’
v(fullDisk1[id]);
^
prog.c:342:1: error: ‘location’ undeclared (first use in this function)
location
^~~~~~~~
prog.c:343:1: error: expected ‘;’ before ‘for’
for(i = 1; i < seek; i++){ }
^~~
prog.c:348:21: error: ‘Disk’ undeclared (first use in this function)
cout << "Disk 1 Completes I/O operation." << endl;
^~~~
prog.c:348:26: error: expected ‘;’ before numeric constant
cout << "Disk 1 Completes I/O operation." << endl;
^
prog.c:352:3: error: ‘operationComplete1’ undeclared (first use in this function)
v(operationComplete1[id]);
^~~~~~~~~~~~~~~~~~
prog.c:354:1: error: ‘complete’ undeclared (first use in this function)
complete
^~~~~~~~
prog.c:355:1: error: expected ‘;’ before ‘}’ token
}
^
prog.c:327:8: warning: unused variable ‘seek’ [-Wunused-variable]
int i, seek; //Check for out of while(countdisk < 25){
^~~~
prog.c:327:5: warning: unused variable ‘i’ [-Wunused-variable]
int i, seek; //Check for out of while(countdisk < 25){
^
prog.c: In function ‘Disk2’:
prog.c:360:1: error: unknown type name ‘requests’
requests
^~~~~~~~
prog.c:361:3: error: expected declaration specifiers or ‘...’ before ‘physicalio2’
p(physicalio2[id]);
^~~~~~~~~~~
prog.c:363:1: error: unknown type name ‘locations’
locations
^~~~~~~~~
prog.c:364:3: error: expected declaration specifiers or ‘...’ before ‘mutexDisk2’
p(mutexDisk2[id]);
^~~~~~~~~~
prog.c:366:1: error: ‘I’ undeclared (first use in this function)
I/O request
^
prog.c:366:3: error: ‘O’ undeclared (first use in this function)
I/O request
^
prog.c:366:5: error: expected ‘;’ before ‘request’
I/O request
^~~~~~~
prog.c:369:1: error: unknown type name ‘shared’
shared resources
^~~~~~
prog.c:370:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘v’
v(mutexDisk2[id]);
^
prog.c:372:1: warning: statement with no effect [-Wunused-value]
2
^
prog.c:373:1: error: expected ‘;’ before ‘v’
v(fullDisk2[id]);
^
prog.c:375:1: error: ‘location’ undeclared (first use in this function)
location
^~~~~~~~
prog.c:376:1: error: expected ‘;’ before ‘for’
for(i = 1; i < seek; i++){}
^~~
prog.c:379:11: error: ‘lt’ undeclared (first use in this function)
cout << "Disk 2 Completes I/O operation." << endl;
^~
prog.c:379:16: error: ‘quot’ undeclared (first use in this function)
cout << "Disk 2 Completes I/O operation." << endl;
^~~~
prog.c:379:21: error: ‘Disk’ undeclared (first use in this function)
cout << "Disk 2 Completes I/O operation." << endl;
^~~~
prog.c:379:26: error: expected ‘;’ before numeric constant
cout << "Disk 2 Completes I/O operation." << endl;
^
prog.c:379:68: error: ‘endl’ undeclared (first use in this function)
cout << "Disk 2 Completes I/O operation." << endl;
^~~~
prog.c:381:14: error: subscripted value is neither array nor pointer nor vector
v(opComplete2[id]);
^
prog.c:383:1: error: ‘complete’ undeclared (first use in this function)
complete
^~~~~~~~
prog.c:384:1: error: expected ‘;’ before ‘}’ token
}
^
prog.c:358:8: warning: unused variable ‘seek’ [-Wunused-variable]
int i, seek; //Local variables while(countdisk < 25){
^~~~
prog.c:358:5: warning: unused variable ‘i’ [-Wunused-variable]
int i, seek; //Local variables while(countdisk < 25){
^
prog.c: At top level:
prog.c:385:1: error: expected identifier or ‘(’ before ‘}’ token
}
^
prog.c:386:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main(){
^~~~
prog.c: In function ‘main’:
prog.c:388:1: warning: implicit declaration of function ‘initialsem’ [-Wimplicit-function-declaration]
initialsem(fullUser, 1);
^~~~~~~~~~
prog.c:391:16: error: ‘lt’ undeclared (first use in this function)
for( z = 0; z < USERS; z++ ){
^~
prog.c:391:1: warning: statement with no effect [-Wunused-value]
for( z = 0; z < USERS; z++ ){
^~~
prog.c:391:25: error: expected ‘)’ before ‘;’ token
for( z = 0; z < USERS; z++ ){
^
prog.c:392:22: error: subscripted value is neither array nor pointer nor vector
initialsem(reqService[z], 0);
^
prog.c:394:1: warning: statement with no effect [-Wunused-value]
for( z = 0; z < DRIVERS; z++){
^~~
prog.c:394:27: error: expected ‘)’ before ‘;’ token
for( z = 0; z < DRIVERS; z++){
^
prog.c:397:12: error: ‘mutexDriver1’ undeclared (first use in this function)
initialsem(mutexDriver1[z], 1); initialsem(fullDriver2[z], 1);
^~~~~~~~~~~~
prog.c:402:22: error: subscripted value is neither array nor pointer nor vector
initialsem(mutexDisk1[z], 1);
^
prog.c:405:22: error: subscripted value is neither array nor pointer nor vector
initialsem(mutexDisk2[z], 1);
^
prog.c:406:29: error: subscripted value is neither array nor pointer nor vector
initialsem(operationComplete[z], 0);
^
prog.c:407:23: error: subscripted value is neither array nor pointer nor vector
initialsem(opComplete2[z], 0);
^
prog.c:410:1: error: ‘cobegin’ undeclared (first use in this function)
cobegin{
^~~~~~~
prog.c:410:8: error: expected ‘;’ before ‘{’ token
cobegin{
^
At top level:
prog.c:326:6: warning: ‘Disk1’ defined but not used [-Wunused-function]
void Disk1( int id ){
^~~~~
prog.c:263:6: warning: ‘Driver2’ defined but not used [-Wunused-function]
void Driver2( int id ){
^~~~~~~
Standard output is empty