494 33 Powerpoint-Slides Ch6 Unix
494 33 Powerpoint-Slides Ch6 Unix
Programming
B. M. Harwani
Manipulating Processes
and Signals
Kernel mode In kernel mode, the system processes, that is, the processes related to
managing a computer system and its resources get executed. The processes used to
allocate memory to access hardware peripherals such as printer and disk drive run in
this mode. These processes are critical in nature, that is, they can make an operating
system inconsistent if they are not handled properly. Hence for security reasons,
these processes are run in a privileged protection mode.
• Text: It represents the program code, that is, the executable instructions.
• Data: It represents the program variables and other data processed by the
program code. It is a global content that can be accessed by the program and
its subroutines (if any).
• Stack: It represents a program segment that is used while implementing
procedure calls for storing information pertaining to parameters, return
addresses, etc.
fg :Foreground Jobs
Jobs that require a high level of user interaction are executed as
foreground jobs. In addition, the most preferred jobs, whose results we
want to see immediately, are executed in the foreground.
Syntax fg [%job]
Here, %job represents the job we wish to run in the foreground.
Syntax bg [%job]
Here, %job represents the job we wish to run in the
background.
Unreliable Signals
Unreliable signals are those that are lost or cannot work properly in the
absence of their signal handlers. For a signal to work properly, it is required
that its signal handler exists or is installed before the signal is generated. In
the absence of the signal handler, the default action is taken, that is, the signal
is lost or killed.
© Oxford University Press 2013. All rights
Sending Signals Using kill() & raise ()
The two functions used to send signals are kill() and raise().
kill()
The syntax for kill() is as follows:
Syntax : int kill(int pid, int signal)
Here, pid is the non-zero (positive) process identifi er to which the signal is
sent.
raise()
The syntax for raise() is as follows:
Syntax : int raise(int signal)
Here, signal represents the integer value or symbolic constant of the signal
that we wish to send to the executing program.
sleep function
The sleep function suspends the execution of a process for the
specified interval of time.
Syntax : unsigned sleep(unsigned seconds);