Reference no: EM131232028
Repeat Exercise 3.22, this time using Windows shared memory. In particular, using the producer-consumer strategy, design two programs that communicate with shared memory using the Windows API as outlined in Section 9.7.2. The producer will generate the numbers specified in the Collatz conjecture and write them to a shared memory object. The consumer will then read and output the sequence of numbers from shared memory. In this instance, the producer will be passed an integer parameter on the command line specifying how many numbers to produce (for example, providing 5 on the command line means the producer process will generate the first five numbers).
Exercise 3.22
In Exercise 3.21, the child process must output the sequence of numbers generated from the algorithm specified by the Collatz conjecture because the parent and child have their own copies of the data. Another approach to designing this program is to establish a shared-memory object between the parent and child processes. This technique allows the child to write the contents of the sequence to the shared-memory object. The parent can then output the sequence when the child completes. Because the memory is shared, any changes the child makes will be reflected in the parent process as well.
This program will be structured using POSIX shared memory as described in Section 3.5.1. The parent process will progress through the following steps:
a. Establish the shared-memory object (shm open(), ftruncate(), and mmap()).
b. Create the child process and wait for it to terminate.
c. Output the contents of shared memory.
d. Remove the shared-memory object.
One area of concern with cooperating processes involves synchronization issues. In this exercise, the parent and child processes must be coordinated so that the parent does not output the sequence until the child finishes execution. These two processes will be synchronized using the wait() system call: the parent process will invoke wait(), which will suspend it until the child process exits.
Exercise 3.21
The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm:

The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, if n = 35, the sequence is
35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1
Write a C program using the fork() system call that generates this sequence in the child process. The starting number will be provided from the command line. For example, if 8 is passed as a parameter on the command line, the child process will output 8, 4, 2, 1. Because the parent and child processes have their own copies of the data, it will be necessary for the child to output the sequence. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program. Perform necessary error checking to ensure that a positive integer is passed on the command line.
Write a program that implements the fifo and lru
: Implement the replacement algorithms so that the number of page frames can vary from 1 to 7. Assume that demand paging is used.
|
Improve productivity and patient satisfaction
: What would the president and medical director want to know before making any financial and organizational decisions - develop recommendations to improve productivity and patient satisfaction.
|
Define what each of these constructs means
: Tannen points out that a common communication strategy is to convey intended messages indirectly. What points does she make about this? Why do people convey messages indirectly? What are its advantages? What are its disadvantages? Illustrate your ..
|
Describe current status in your leadership development
: Leadership is creativity in action. It is the ability to see the present in terms of the future while maintaining respect for the past. Based on the above definition, describe for me your current status in your leadership development.
|
Create the child process and wait for it to terminate
: In Exercise 3.21, the child process must output the sequence of numbers generated from the algorithm specified by the Collatz conjecture because the parent and child have their own copies of the data. Another approach to designing this program is ..
|
Evaluate the role of ethical decision-making in business
: Discuss the key countries that might be associated with the risk. Evaluate the role of ethical decision-making in business organizations. Analyze the impact of business ethics on stakeholder relationships.
|
Find the total return over the 36-month period
: FIN 132 - Efficient Frontier (Risk and Return) - Find the total return over the 36-month period for each stock. Which stock had the highest and lowest returns? Was this expected? Are these results consistent with the general risk-return relationshi..
|
Design the wl ratios of the transistors
: Design the W/L ratios of the transistors to provide symmetrical switching times equal to the basic CMOS inverter with (W/L)n = 2 and (W/L)p = 4.
|
Describe the negative impact the project would face
: Identify at least four significant team communication challenges she would be facing on this project that would be tied to the fact that she was working with a virtual team. Explain carefully the problems associated with each challenge.
|