02 ProcessAbstraction
02 ProcessAbstraction
What is a “process”?
Operations on processes
Reference
Chapter 3 of Operating Systems, 3rd edition by Deitel et. al
What is a Process?
A process is a program in execution
An instance of a program running in a computer
When a process is
dispatched to be OS decides to
executed by the CPU, it switch a
transitions from ready process from
to running running to
ready
When a process is
“completely” terminated,
OS removes the process
from the process table and
frees all of the process’s
resources
12
Current
per core
PCB
Ready
Blocked
OS maintains a ready
list and a blocked list
that store references
to processes not
currently running
13
You can list the processes’ details in Linux/Mac OS X by using ps
command
Usage: ps [option]
When executed without any options, only processes that are associated with
the current terminal are shown.
15
Operating systems provide fundamental services to processes
including:
Creating processes
Destroying processes
Suspending processes
Resuming processes
Changing process’s priority (for scheduling)
Waiting for a process (parent process waits for the child process)
Check process’s status
Interprocess communication (IPC)
:
Set the process state to Ready and put it to the Ready queue
Windows API
CreateProcess() function
Creates a new process and its primary thread and loads program for execution
http://msdn.microsoft.com/en-us/library/ms682512(VS.85).aspx
CreateProcess() similar to fork() + exec ()
interrupt
e.g., parent process using kill() system call to kill the child process
Process Process
X OS Y
signal
27
A process can decide whether it wants to catch, ignore or
mask a signal
Catching a signal involves specifying a routine (signal handler) in
advance so that the OS will invoke that handler when the process
receives that signal
the signal() or sigaction() system calls can be used by the program to specify the
signal handler routine to the OS
Catching – Using OS's default action to handle the signal
Ignore – Inform OS that it does not want to handle that signal
Masking a signal is to instruct the OS not to deliver signals of that type
until the process clears the signal mask