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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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