C programming work -- 2
Dibayar semasa penghantaran
You will work with the provided producer_template.c and consumer_template.c source files. Rename them to producer.c and consumer.c after writing your code.
Do not modify the low-level functions for reading from and writing to shared memory; use the provided functions.
Compile your programs using the following commands:
gcc producer.c -lrt -o producer
gcc consumer.c -lrt -o consumer
Accept three command-line arguments as integers:
bufSize: Size of the bounded buffer (2 to 500).
itemCnt: Number of items to produce/consume (greater than 0).
randSeed: Seed for the random number generator.
Create a shared memory block with a fixed size of 4K, named OS_HW1_yourName.
Initialize the shared memory block's header with:
in: Index of the next item to be produced
out: Index of the next item to be consumed
Fork a child process and load the consumer executable into it.
Use the Producer() function to generate random integers (5 to 2500) and write them into the bounded buffer. If the buffer is full, wait until the consumer consumes an item.
Open and map the shared memory block created by the producer, named OS_HW1_yourName.
Read the four integer values from the header.
Read all the items written by the producer to the shared memory buffer (itemCnt). If the buffer is empty, wait until the producer produces more items.
Follow the provided pseudo-code for bounded-buffer producer/consumer.
Use provided functions for reading and writing shared variables.
Utilize the GetRand() function for generating random numbers.
ID Projek: #37251917
19 pekerja bebas membida secara purata ₹20500 untuk pekerjaan ini
I am an experienced C/C++ developer. I have 3 years of experience in Linux system programming and the POSIX standard. Your task is easy to me. I believe I can help you in this task. Thank you.
Hello! I will perfectly complete your C programming work, based on my strong C/C++/C# Programming experience in 1 day. Please open the chat with me so that I can start working for you. Regards.