Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All codes should be written in C. Write a program that forks to create two children. The parent then sleeps and wakes up every 10

All codes should be written in C.

Write a program that forks to create two children. The parent then sleeps and wakes up every 10 seconds. Each time it wakes up it sends a signal SIGUSR1 to the first child and SIGUSR2 to the second child. After two minutes it interchanges the signal sent and sends SIGUSR2 to the first child and SIGUSR1 to the second child and continues for a further 2 minutes. The children, each, keeps two counters C1 and C2. C1 is initially 0 while C2 is initially 1. Whenever a child receives a signal SIGUSR1, it increments C1 by 1 and when it receives SIGUSR2 it multiplies C2 by 2. In either case it displays its pid and both C1 and C2.

The setitimer() call allows the programmer to reset a timer at a regular time interval. It also provides for finer time intervals than the alarm, since it can set the timer at milliseconds. Check its use and write a program that opens a file, triggers a timer every 500 ms, write in the file the total time elapsed since it started executing, every time the timer is triggered. The program should run for a total of 30 seconds.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Public Sector Accounting And Finance

Authors: Prof Stephen Sunday Sharang Ph.D.

1st Edition

979-8639273353

More Books

Students also viewed these Accounting questions

Question

Define agreement.

Answered: 1 week ago