Write a simple program called ring

Assignment Help C/C++ Programming
Reference no: EM132915157

You will write a simple program called ring that creates a ring of N processes that send a signal round and round cnt times. The program is invoked with ./ring N leader cnt where leader is 0 when you first invoke it. The program works as follows. If the leader parameter is 0 then it knows it is the leader. It then creates (with fork-exec) a child process that has parameters leader cnt where now leader is the PID of the true leader process. The child then will create another child process with parameters leader cnt where now leader is again the PID of the true leader process. The process that eventually is created with N=1 is the last one and it does not create another child. Instead sends a SIGUSR1 to the leader to start everything. All the process suspend themselves waiting for a SIGUSR1 and then send a SIGUSR1 to the next one. At the end of the execution the leader (only) prints the cnt and the true time elapsed since the beginning of execution as a floating point number. Also write a script ring_time.sh using a for loop that runs the ring program for N=20 processes and for cnt10, 100, 1000 and 10000 signals and writes the results in the file timing.out. The format of the file timing.

out is the results of one run per line and each line contains the cnt and the time it took.

Your code should be properly commented, indented and readable. There should be a comment near the top of the file that includes a short description (3-4 lines), your name and date. Compilation should produce no warnings on the EECS Linux systems. All system calls that may return an error condition should be checked. Please keep in mind that style is very important.

Besides the code in the notes, you should read several man pages. Pages like kill(2), sigaction(2), fork(2), signal(7), errno(3), sigsuspend(2), clock_gettime(2) are good starting points.

Process starts with the main process , it creates one child, which in turn creates another child and so on until n children are created .

Thr last child doesn't create any child , instead send sigusr1 signal to the main process to start execution
After receiving the sigusr1 , it gives kill signal to its child , and suspends using sigsuspend
After that , it send signal to another child and suspends itself and so on until each process sends "cnt" number of signal

Attachment:- Simple program.rar

Reference no: EM132915157

Questions Cloud

Explain difference between authorized stock and issue stock : Explain the difference between "authorized" stock and "issued" stock. When stock is issued/sold what amount is credited to "paid-in-capital"?
Talk about external factors in international business : Can you mention and talk about external factors in international business? (example: political, legal, economic, cultural, etc.) and how these can impact busine
Short-term incentives versus long-term incentives : Compare and contrast when it would be preferable to motivate employee performance through short-term incentives versus long-term incentives
Create and capture value from global expansion : 1) Toyota customers have a wide range of preferences. Some prefer the fuel economy of a hybrid (Prius), some prefer a family van (Odyssey), and others may prefe
Write a simple program called ring : Write a simple program called ring that creates a ring of N processes that send a signal round and round cnt times. The program is invoked with
How does organisational influences affect ethical behaviour : How does organisational influences affect ethical behaviour?
Recognize poor inventory management : What are the ways to recognize poor inventory management and how inventory management contributes to least total cost logistics?
Why companies choose fifo method of accounting for gaap : Why companies choose FIFO method of accounting for GAAP. Also, explain why companies choose LIFO method of accounting for tax purposes.
Bloom digital taxonomy verbs and samr model : The Bloom's Digital taxonomy verbs and SAMR model and develop an activity BASED on one of these models.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Submit your finished yahtzee game

Accurate calculations of points scored by each of the players - It is time for you to submit your finished Yahtzee game.

  Write a function that permanently swaps two integers

Write a function that permanently swaps two integers using pointers.

  Write a program to check the number

Write a program that asks the user to enter an integer from 1 to 50

  Prompt the user for and read 6 numbers

Write a program using an array that will store input data. Prompt the user for and read 6 numbers between 70 and 90. Verify the numbers should be greater than 70 and less than 90. If the number is less than or equal to 70 or greater than 90, repro..

  Components of the position and velocity vectors

This is embodied in the governing ODE above, and dictates the motion of the planets and other orbiting bodies. But what if the laws of physics were different? What if the force weren't inversely-proportional to the distance squared, but instead to..

  Questions about experimental designs

Jackson, even-numbered Chapter Exercises, pp. 335-337. Explain the difference between multiple independent variables and multiple levels of independent variables. Which is better? What is blocking and how does it reduce "noise"? What is a disadvantag..

  Write c function to perform complex addition and subtraction

Write C functions to perform complex addition, subtraction, multiplication, and division using the complex structure dis­ cussed in this chapter. Add these functions to the calculator program. You will have to allow the user to specify a complex v..

  Setup a class to store a book

Setup a class to store a book. The data is to include title, author, year of publication, dewey number and age.

  Feature of object-oriented programming

Describe at least one (1) feature of object-oriented programming that Visual Logic lacks and Identify at least one (1) advantage to using event-driven programming, as compared to using purely procedural programming

  Draw the heap

Eric Rowe Starting with an empty minheap, draw the heap after each the completion of the following operations  and repeat for a maxheap (replace removeMin() with removeMax()). Upload your drawings here. Hand drawn is fine:

  Adjacency matrix and shortest path

Construct a graph based on the adjacency matrix that appears below. Label all nodes with indices consistent with the placement of numbers within the matrix.

  Prepare a program to print the permutation

write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd