Question: Modify the code to achieve the same results using only two processes. (A single process begins executing the main program. The process calls create twice

Modify the code to achieve the same results using only two processes.

(A single process begins executing the main program. The process calls create twice to start two new processes, that will execute code from function sndch (so, that would make 3 processes, how to use only two processes?)

/* main.c - main */

#include

void sndch(char);

/*-------------------------------------------------------------------

* main - Example of 2 processes executing the same code concurrently

*--------------------------------------------------------------------

*/

void main(void)

{

resume( create(sndch, 1024, 20, "send A", 1, 'A') );

resume( create(sndch, 1024, 20, "send B", 1, 'B') );

}

/*-------------------------------------------------------------------------

* sndch - Output a character on a serial device indefinitely

*---------------------------------------------------------------------------

*/

void sndch (char ch)

{

while(1)

putc(CONSOLE, ch);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!