Question: what is a C code that solves these problems? In the following questions, f 1 ( ) , f 2 ( ) , f 3

what is a C code that solves these problems?
In the following questions, f1(), f2(), f3() are thread functions. Use semaphores to obtain the result as requested in each equation.
The solution code MUST contain PThreads and Semaphores.
[1]
void *f1(void *arg)
{
printf(first);
}
void *f2(void *arg)
{
printf(Second);
}
void *f3(void *arg)
{
printf(Third);
}
The required result on screen monitor is
First
Second
Third
[2]
??* global variables*
int m=0;
int n=0;
void *f1(void *arg)
{
m =10;
}
void *f2(void *arg)
{
n =14;
}
void *f3(void *arg)
{
int r;
r = m + n;
printf(r =%d, r);
}
The required result on screen monitor is
r=24
[3]
int a =0;
int b =0;
int c =0;
void *f1(void *arg)
{
int r;
a =1;
r = a + b + c;
printf(r =%d, r);
}
void *f2(void *arg)
{
int r;
b =2;
r = a * b * c;
printf(r =%d, r);
}
void *f3(void *arg)
{
int r;
c =6;
r = c - a - b ;
printf(r =%d, r);
}
** The required result on screen monitor is
r=9
r=12
r=3
** The order of the output is not important. So, this output is also valid
r=12
r=3
r=9
 what is a C code that solves these problems? In the

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!