Write a C program that illustrates suspending and resuming processes using signals
AIM:
Write a C program that illustrates suspending and resuming processes using signals
Program:
#include <stdio.h> #include <ospace/unix.h> int child_function() { while (true) // Loop forever. { Printf("Child loop\n"); os_this_process::sleep( 1 ); } return 0; // Will never execute. } int main() { os_unix_toolkit initialize; os_process child ( child function ); // Spawn child. os_this_process::sleep( 4 ); printf("child.suspend()\n"); child.suspend(); printf("Parent sleeps for 4 seconds\n"); os_this_process::sleep (4); printf("child.resume()"); child.resume (); os_this_process::sleep (4); printf("child.terminate()"); child.terminate (); printf("Parent finished"); return 0; }
Output:
Child loop
Child loop
Child loop
Child loop
Child loop
child.suspend()
Parent sleeps for 4 seconds
child.resume()
Child loop
Child loop
Child loop
Child loop
child.terminate()
Child loop
Parent finished
-
UpdatedOct 23, 2014
-
Views11,815
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.