Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Processes I<br />
Handling Signals<br />
- process exists on receipt of signal, or<br />
- it ignores <strong>the</strong> signal, or<br />
- it executes a user function on receipt of signal<br />
oldfunction = signal (signum, function);<br />
signum - signal number to specify action function - address of user function to invoke<br />
algorithm psig /* handle signals after recognizing <strong>the</strong>ir existence */<br />
input: none<br />
output: none<br />
{<br />
get signal number set in process table entry;<br />
clear signal number in process table entry;<br />
if (user had called signal sys call to ignore this signal)<br />
return; /* done */<br />
if (user specified function to handle <strong>the</strong> signal)<br />
{<br />
get user virtual address of signal catcher stored in u area;<br />
/* <strong>the</strong> next statement has undesirable side-effects */<br />
clear u area entry that stored address of signal catcher;<br />
modify user level context:<br />
artificially create user stack frame to mimic call to<br />
signal catcher function;<br />
modify system level context:<br />
write address of signal catcher into program counter<br />
field of user saved register context;<br />
return;<br />
}<br />
if (signal is type that system should dump core image of process)<br />
{<br />
create file named "core" in current directory;<br />
write contents of user level context to file "core";<br />
}<br />
invoke exit algorithm immediately;<br />
}<br />
Figure 26. Algorithm for Handling<br />
Signals<br />
If <strong>the</strong> signal handling function is set to its default value, <strong>the</strong> kernel will dump a "core" image of <strong>the</strong> process for<br />
certain types of signals before exiting.<br />
The <strong>Unix</strong> Model<br />
C Language<br />
<strong>Unix</strong> Networking is almost exclusively written in C.<br />
Two flavors: ANSI C<br />
Standard C<br />
Standard C Library<br />
/ lib/ libc. a<br />
standard I/O library, malloc, etc<br />
system calls - read, write, ioctl, pipe,<br />
etc<br />
<strong>Unix</strong> Versions<br />
System V:<br />
interprocess communication facilities:<br />
message queues, semaphores, and shared memory<br />
remote file system, streams,<br />
transport layer interface (TLI),<br />
transport provider interface (TPI),<br />
file and record locking<br />
Release 1 (1983), 2 (1984), 3 (1986), 4<br />
(1989)<br />
Berkeley Software Distributions (BSD)<br />
source code implementation of TCP/IP,<br />
Berkeley socket interface<br />
Release 4.1 (1983), 4.3 (1988)<br />
Kernel<br />
Operating system provides services such as:<br />
filesystem,<br />
memory management,<br />
CPU scheduling,<br />
device I/O.<br />
Typically <strong>the</strong> kernel interacts directly <strong>with</strong> h/w<br />
Program<br />
Executable file created by <strong>the</strong> link editor.<br />
Run by issuing <strong>the</strong> exec system call<br />
108