fork download
  1. #include<stdio.h>
  2. #include<ctype.h>
  3. #include <semaphore.h>
  4. #include <sys/types.h>
  5. #include <pthread.h>
  6. #include <unistd.h>
  7.  
  8. const int user;
  9.  
  10. const int COUNTER = 5; //Number of I/O requests per each int TOTAL = 25;
  11. int DRIVERS = 2;
  12. int USERS = 5; //Total number of I/O requests
  13. //Total number of Drivers
  14. //Number of Users //Semaphores for User
  15. sem_t fullUser;
  16. sem_t ioReq;
  17. //binarysem mutexUser; //User buffer at max
  18. sem_t mutexUser;
  19. sem_init(&mutexUser, 0, 1); /* initialize mutex to 1 - binary semaphore */
  20.  
  21. //User buffer at empty
  22. //User buffer protect //Semaphores for Driver 1
  23. sem_t fullDriver1[DRIVERS];
  24. sem_t reqPend[DRIVERS];
  25. //binarysem mutexDriver1[DRIVERS]; //Driver 1 buffer at max
  26. sem_t mutexDriver;
  27. /* Create the mutexDriver semaphore and initialize to DRIVERS buffer size */
  28. sem_init(&mutexDriver, 0, DRIVERS);
  29.  
  30. //Driver 1 buffer at empty
  31. //Driver 1 buffer protect //Semaphores for Driver 2
  32. sem_t fullDriver2[DRIVERS];
  33. sem_t reqPend2[DRIVERS];
  34. //binarysem mutexDriver2[DRIVERS]; //Driver 2 buffer at max
  35. sem_t mutexDriver2;
  36. sem_init(&mutexDriver2, 0, DRIVERS);
  37.  
  38. //Driver 2 buffer at empty
  39. //Driver 2 protect //Semaphores for Disk 1
  40. sem_t fullDisk1[DRIVERS];
  41. sem_t physicalio1[DRIVERS];
  42. //binarysem mutexDisk1[DRIVERS]; //Disk buffer at max
  43. sem_t mutexDisk1;
  44. sem_init(&mutexDisk1, 0, DRIVERS);
  45.  
  46. //Disk buffer at empty
  47. //Disk buffer protect //Semaphores for Disk 2
  48. sem_t physicalio2[DRIVERS];
  49. sem_t fullDisk2[DRIVERS];
  50. //binarysem mutexDisk2[DRIVERS]; //Disk buffer at empty
  51. sem_t mutexDisk2;
  52. sem_init(&mutexDisk2, 0, DRIVERS);
  53.  
  54. //Disk buffer at max
  55. //Disk buffer protect //Other semaphores
  56. //binarysem reqService[USERS];
  57. sem_t reqService;
  58. sem_init(&reqService, 0, USERS);
  59.  
  60. //binarysem operationComplete[DRIVERS];
  61. sem_t operationComplete;
  62. sem_init(&operationComplete, 0, DRIVERS);
  63.  
  64. //binarysem opComplete2[DRIVERS];
  65. sem_t opComplete2;
  66. sem_init(&opComplete2, 0, DRIVERS);
  67.  
  68.  
  69. //binarysem print; //I/O request protect
  70. sem_t print;
  71. sem_init(&print, 0, 1);
  72.  
  73. //Disk protection
  74. //Disk 2 protection
  75. //Print protection //globals
  76. int idUser;
  77. int addrUser;
  78. int devUser;
  79. int idIorq[DRIVERS];
  80. int addrIorq[DRIVERS];
  81. int pio[DRIVERS];
  82. int countdriver = 0;
  83. int countdisk = 0; //User/Doio id buffer
  84. //User/Doio address buffer
  85. //User/Doio device buffer
  86. //Doio/Driver user id buffer
  87. //Doio/Driver address id buffer
  88. //Driver/Disk
  89. //Counter for Driver
  90. //Counter for Disk void User(int id) {
  91. int i, addr, dev; //Local variables used for(i = 0; i &lt; COUNTER; i++)
  92. {
  93. //Loop through the
  94. number of requests
  95. addr = random(200) + 1;
  96. //Generating random I/O information
  97. dev = random(2);
  98. //Generating random Driver assignment
  99. p(fullUser);
  100. //Decrement available buffer locations
  101. between User and DOIO
  102. p(mutexUser);
  103. //Exclusive access to I/O request idUser = id;
  104. //Passing user id to shared resource
  105. addrUser = addr;
  106. //Passing address to shared resource
  107. devUser = dev;
  108. //Passing driver id to shared resource
  109. p(print);
  110. //Gaining control of the printer
  111. cout &lt;&lt; &quot;User &quot; &lt;&lt; id &lt;&lt; &quot; executes system call SIO or DOIO&quot; &lt;&lt; endl; v(print);
  112. v(mutexUser); //Released control of the printer
  113. //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
  114. pending
  115. operation.
  116. } } void Doio(){
  117. int j, idIorb, addrIorb, devIorb;
  118. for( j = 0; j &lt; TOTAL; j++)
  119. through the total requests
  120. {
  121. p(ioReq);
  122. sent a request
  123. p(mutexUser);
  124. request
  125. idIorb = idUser;
  126. addrIorb = addrUser;
  127. devIorb = devUser;
  128. v(mutexUser);
  129. I/O request
  130. v(fullUser);
  131. buffer locations between User and DOIO
  132. // //Local variables used
  133. //For loop that goes
  134. //Checking to see if user
  135. //Exclusive access to I/O
  136. //Copying user ID into DOIO
  137. //Copying address into DOIO
  138. //Copying driver ID into DOIO
  139. //Releasing editting control of
  140. //Incrementing available Ending consuming process p(fullDriver1[devIorb]);
  141. //Decrementing available buffer
  142. locations
  143. p(mutexDriver1[devIorb]);
  144. //Exclusive access to I/O
  145. request
  146. idIorq[devIorb] = idIorb;
  147. //Passing user to shared
  148. source
  149. addrIorq[devIorb] = addrIorb;
  150. //Passing address
  151. information to shared resource
  152. v(mutexDriver1[devIorb]);
  153. //Releasing editting control
  154. of I/O request
  155. v(reqPend[devIorb]);
  156. //Inform Driver request is
  157. pending
  158. p(print);
  159. //Gain control of printer
  160. cout &lt;&lt; &quot;DOIO assembles IORB and inserts it into IORQ for User &quot; &lt;&lt;
  161. idIorb &lt;&lt; endl;
  162. v(print);
  163. //Release control of printer
  164. // Begin consuming process
  165. p(ioReq);
  166. request
  167. p(mutexUser);
  168. request
  169. idIorb = idUser;
  170. addrIorb = addrUser;
  171. devIorb = devUser; //Checking to see if user sent a
  172. //Exclusive access to I/O
  173. //Copying user into DOIO
  174. //Copying address into DOIO
  175. //Copying driver ID into DOIO request v(mutexUser); //Releasing control of I/O v(fullUser);
  176. //Incrementing available
  177. buffer locations
  178. //Begin producing process
  179. p(fullDriver2[devIorb]);
  180. //Decrementing available
  181. buffer location
  182. p(mutexDriver2[devIorb]);
  183. //Exclusive access to I/O
  184. request
  185. idIorq[devIorb] = idIorb;
  186. //Passing user into shared
  187. source
  188. addrIorq[devIorb] = addrIorb;
  189. //Passing addr into shared
  190. source
  191. cout &lt;&lt; &quot;DOIO assembles IORB and inserts it in IORQ2 for User &quot; &lt;&lt;
  192. idIorb &lt;&lt; endl;
  193. v(mutexDriver2[devIorb]);
  194. //Releasing control of I/O
  195. request
  196. v(reqPend2[devIorb]);
  197. //Inform driver request is
  198. pending
  199. }
  200. }
  201. void Driver1( int id ){
  202. int idDriver, addrDriver, k;
  203. //Local variables
  204. p(reqPend[id]);
  205. //Check to see if there
  206. is a request from DOIO
  207. while(countdriver &lt; 25){
  208. //Loop through the
  209. requests
  210. if ( countdriver == 25 ) {
  211. //Check for out of
  212. bounds
  213. v(reqPend2[k]);
  214. break;
  215. }
  216. p(mutexDriver1[id]);
  217. //Gain exclusive editting
  218. access to IORQ
  219. idDriver = idIorq[id];
  220. //Copy user ID into Driver
  221. addrDriver = addrIorq[id];
  222. //Copy address into Driver
  223. v(mutexDriver1[id]);
  224. //Release editting control
  225. of I/O request
  226. v(fullDriver1[id]);
  227. //Increment available buffer
  228. location by 1
  229. p(print);
  230. //Control of printer
  231. cout &lt;&lt; &quot;Driver 1 initiates I/O operation for user &quot; &lt;&lt; idDriver &lt;&lt;
  232. endl;
  233. v(print);
  234. //Release control of printer
  235. p(fullDisk1[id]);
  236. //Decrement available
  237. buffer locations
  238. p(mutexDisk1[id]);
  239. //Gain access to Disk
  240. request
  241. pio[id] = addrDriver;
  242. //Pass adress to shared
  243. resource
  244. p(print);
  245. cout &lt;&lt; &quot;Driver 1 signals User &quot; &lt;&lt; idDriver &lt;&lt; &quot;that the operation
  246. is complete.&quot; &lt;&lt; endl;
  247. countdriver++;
  248. v(print);
  249. v(mutexDisk1[id]);
  250. //Release control of Disk
  251. request
  252. v(physicalio1[id]);
  253. //Inform disk request is
  254. pending
  255. p(operationComplete[id]);
  256. //Waiting for disk operation
  257. to complete
  258. v(reqService[idDriver]);
  259. //Inform user request is complete } if ( countdriver == 25 ) {
  260. v(reqPend[k]);
  261. break;
  262. } //Check for out of bounds }
  263. void Driver2( int id ){
  264. int idDriver2, addrDriver2, i = 0;
  265. //Local variables
  266. p(reqPend2[id]);
  267. //Check to see if there
  268. is a request from DOIO
  269. while( countdriver &lt; 25 ){
  270. //Loop through the
  271. requests
  272. if( countdriver == 25 ){
  273. //Check for out of
  274. bounds
  275. v(reqPend[i]);
  276. break;
  277. }
  278. p(mutexDriver2[id]);
  279. //Gain exclusive access to
  280. I/O request
  281. idDriver2 = idIorq[id];
  282. //Copy user ID into Driver
  283. addrDriver2 = addrIorq[id];
  284. //Copy address into Driver
  285. v(mutexDriver2[id]);
  286. //Release control of Disk
  287. Request
  288. v(fullDriver2[id]);
  289. //Increment available buffer
  290. location
  291. p(print);
  292. //Access printer
  293. cout &lt;&lt; &quot;Driver 2 initiates I/O operation for user &quot; &lt;&lt; idDriver2 &lt;&lt;
  294. endl;
  295. v(print);
  296. //Release access to printer
  297. p(fullDisk2[id]);
  298. //Decerement available
  299. buffer locations
  300. p(mutexDisk2[id]);
  301. //Gain access to Disk 2
  302. request
  303. pio[id] = addrDriver2;
  304. //Pass address to a shared
  305. resource
  306. p(print);
  307. cout &lt;&lt; &quot;Driver 2 signals User &quot; &lt;&lt; idDriver2 &lt;&lt; &quot;that the operation
  308. is complete.&quot; &lt;&lt; endl;
  309. countdriver++;
  310. v(print);
  311. v(mutexDisk2[id]);
  312. //Release control of disk
  313. request
  314. v(physicalio2[id]);
  315. //Inform disk 2 request is
  316. pending
  317. p(opComplete2[id]);
  318. //Waiting for disk 2 to
  319. complete
  320. v(reqService[idDriver2]);
  321. //Inform user the request is
  322. complete
  323. if( countdriver == 25 ){ bounds v(reqPend[i]);
  324. break;
  325. } } }
  326. void Disk1( int id ){
  327. int i, seek; //Check for out of while(countdisk &lt; 25){
  328. p(physicalio1[id]);
  329. //Decrement available buffer
  330. locations
  331. p(mutexDisk1[id]);
  332. //Gain exclusive access to
  333. I/O request
  334. seek = pio[id];
  335. //Grabbing the address from
  336. shared resource
  337. v(mutexDisk1[id]);
  338. //Releasing control of Disk
  339. 1
  340. v(fullDisk1[id]);
  341. //Increment available buffer
  342. location
  343. for(i = 1; i &lt; seek; i++){ }
  344. //Dummy loop that iterates
  345. from i to seek
  346. p(print);
  347. //Gain access to the printer
  348. cout &lt;&lt; &quot;Disk 1 Completes I/O operation.&quot; &lt;&lt; endl;
  349. v(print);
  350. //Release acess to the printer.
  351. countdisk++;
  352. v(operationComplete1[id]);
  353. //Inform Driver operation is
  354. complete
  355. }
  356. }
  357. void Disk2( int id ){
  358. int i, seek; //Local variables while(countdisk &lt; 25){
  359. //Loop through the
  360. requests
  361. p(physicalio2[id]);
  362. //Decrement available buffer
  363. locations
  364. p(mutexDisk2[id]);
  365. //Gain exclusive access to
  366. I/O request
  367. seek = pio[id];
  368. //Grabbing the address from
  369. shared resources
  370. v(mutexDisk2[id]);
  371. //Releasing control of Disk
  372. 2
  373. v(fullDisk2[id]);
  374. //Increment available buffer
  375. location
  376. for(i = 1; i &lt; seek; i++){}
  377. //Dummy loop that iterates
  378. from i to seek
  379. cout &lt;&lt; &quot;Disk 2 Completes I/O operation.&quot; &lt;&lt; endl;
  380. countdisk++;
  381. v(opComplete2[id]);
  382. //Inform Driver operation is
  383. complete
  384. }
  385. }
  386. main(){
  387. int z = 0;
  388. initialsem(fullUser, 1);
  389. initialsem(ioReq, 0);
  390. initialsem(mutexUser, 1);
  391. for( z = 0; z &lt; USERS; z++ ){
  392. initialsem(reqService[z], 0);
  393. }
  394. for( z = 0; z &lt; DRIVERS; z++){
  395. initialsem(fullDriver1[z], 1);
  396. initialsem(reqPend[z],0);
  397. initialsem(mutexDriver1[z], 1); initialsem(fullDriver2[z], 1);
  398. initialsem(reqPend2[z], 0);
  399. initialsem(mutexDriver1[z], 1);
  400. initialsem(fullDisk1[z], 1);
  401. initialsem(physicalio1[z], 0);
  402. initialsem(mutexDisk1[z], 1);
  403. initialsem(fullDisk2[z], 1);
  404. initialsem(physicalio2[z], 0);
  405. initialsem(mutexDisk2[z], 1);
  406. initialsem(operationComplete[z], 0);
  407. initialsem(opComplete2[z], 0);
  408. }
  409. initialsem(print, 1);
  410. cobegin{
  411. User(0);
  412. User(1);
  413. User(2);
  414. User(3);
  415. User(4);
  416. Doio();
  417. Driver1(0);
  418. Driver2(0);
  419. Disk1(0);
  420. Disk2(0);
  421. }
  422. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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 &lt; 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 &lt; TOTAL; j++)
                    ^~~~~
prog.c:118:25: error: expected ‘)’ before ‘;’ token
 for( j = 0; j &lt; 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 &lt; 25){
                        ^~
prog.c:207:26: error: expected ‘;’ before ‘)’ token
 while(countdriver &lt; 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 &lt;&lt; &quot;Driver 1 initiates I/O operation for user &quot; &lt;&lt; idDriver &lt;&lt;
 ^~~~
prog.c:231:7: error: ‘lt’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Driver 1 initiates I/O operation for user &quot; &lt;&lt; idDriver &lt;&lt;
       ^~
prog.c:231:16: error: ‘quot’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Driver 1 initiates I/O operation for user &quot; &lt;&lt; idDriver &lt;&lt;
                ^~~~
prog.c:231:21: error: ‘Driver’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Driver 1 initiates I/O operation for user &quot; &lt;&lt; idDriver &lt;&lt;
                     ^~~~~~
prog.c:231:28: error: expected ‘;’ before numeric constant
 cout &lt;&lt; &quot;Driver 1 initiates I/O operation for user &quot; &lt;&lt; idDriver &lt;&lt;
                            ^
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 &lt;&lt; &quot;Driver 1 signals User &quot; &lt;&lt; idDriver &lt;&lt; &quot;that the operation
                            ^
prog.c:245:83: error: unknown type name ‘that’
 cout &lt;&lt; &quot;Driver 1 signals User &quot; &lt;&lt; idDriver &lt;&lt; &quot;that the operation
                                                                                   ^~~~
prog.c:245:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘operation’
 cout &lt;&lt; &quot;Driver 1 signals User &quot; &lt;&lt; idDriver &lt;&lt; &quot;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 &lt; 25 ){
                         ^~
prog.c:269:28: error: expected ‘;’ before ‘)’ token
 while( countdriver &lt; 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 &lt;&lt; &quot;Driver 2 initiates I/O operation for user &quot; &lt;&lt; idDriver2 &lt;&lt;
                            ^
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 &lt;&lt; &quot;Driver 2 signals User &quot; &lt;&lt; idDriver2 &lt;&lt; &quot;that the operation
                            ^
prog.c:307:84: error: unknown type name ‘that’
 cout &lt;&lt; &quot;Driver 2 signals User &quot; &lt;&lt; idDriver2 &lt;&lt; &quot;that the operation
                                                                                    ^~~~
prog.c:307:93: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘operation’
 cout &lt;&lt; &quot;Driver 2 signals User &quot; &lt;&lt; idDriver2 &lt;&lt; &quot;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 &lt; seek; i++){ }
 ^~~
prog.c:348:21: error: ‘Disk’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Disk 1 Completes I/O operation.&quot; &lt;&lt; endl;
                     ^~~~
prog.c:348:26: error: expected ‘;’ before numeric constant
 cout &lt;&lt; &quot;Disk 1 Completes I/O operation.&quot; &lt;&lt; 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 &lt; 25){
        ^~~~
prog.c:327:5: warning: unused variable ‘i’ [-Wunused-variable]
 int i, seek; //Check for out of while(countdisk &lt; 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 &lt; seek; i++){}
 ^~~
prog.c:379:11: error: ‘lt’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Disk 2 Completes I/O operation.&quot; &lt;&lt; endl;
           ^~
prog.c:379:16: error: ‘quot’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Disk 2 Completes I/O operation.&quot; &lt;&lt; endl;
                ^~~~
prog.c:379:21: error: ‘Disk’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Disk 2 Completes I/O operation.&quot; &lt;&lt; endl;
                     ^~~~
prog.c:379:26: error: expected ‘;’ before numeric constant
 cout &lt;&lt; &quot;Disk 2 Completes I/O operation.&quot; &lt;&lt; endl;
                          ^
prog.c:379:68: error: ‘endl’ undeclared (first use in this function)
 cout &lt;&lt; &quot;Disk 2 Completes I/O operation.&quot; &lt;&lt; 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 &lt; 25){
        ^~~~
prog.c:358:5: warning: unused variable ‘i’ [-Wunused-variable]
 int i, seek; //Local variables while(countdisk &lt; 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 &lt; USERS; z++ ){
                ^~
prog.c:391:1: warning: statement with no effect [-Wunused-value]
 for( z = 0; z &lt; USERS; z++ ){
 ^~~
prog.c:391:25: error: expected ‘)’ before ‘;’ token
 for( z = 0; z &lt; 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 &lt; DRIVERS; z++){
 ^~~
prog.c:394:27: error: expected ‘)’ before ‘;’ token
 for( z = 0; z &lt; 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 ){
      ^~~~~~~
stdout
Standard output is empty