Question:
We would like to design and implement a programming solution
to the reader-writer problem
using semaphores in C language under UNIX.
We assume that we have three readers and two writers
processes that would run concurrently.
A writer is to update (write) into one memory location
(let’s say a variable of type integer named
temp initialized to 0). In the other hand, a reader is to
read the content of temp and display its
content on the screen in a formatted output. One writer can
access the shared data exclusively
without the presence of other writer or any reader, whereas,
a reader may access the shared
memory for reading with the presence of other readers (but
not writers).
Answer / lina wahab
1- Displays a message that declares the id of the writer
and that it starts the updating
2- Sleeps a random number of seconds between 2 and 4
seconds [2, 4].
2- Increments the content of the shared data
3- Displays a message that declares the id of the writer
and that it finishes the updating
A reader process should read the content of the shared data
and displayed it on the
screen as following:
For each access to shared data for reading:
1- Sleeps a random number of seconds between 2 and 3
seconds [2, 3].
2- displays in one line: the content of the shared data as
well as the id of itself (the reading
process).
Important notes:
1. Let each process run up to 10 iterations.
2. Your solution should ensure the non starvation of readers
Is This Answer Correct ? | 1 Yes | 3 No |
void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }
Is this code legal? int *ptr; ptr = (int *) 0x400;
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
Write a Program that Inputs 10 Numbers in an Array and Show the Maximum Number
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }
Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.
why java is platform independent?
Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.
find A^B using Recursive function
Finding a number which was log of base 2
#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }
main() { printf("%x",-1<<4); }