Processes and Threads Flashcards
(118 cards)
How do processors execute instructions?
1) Fetches the instructions from memory 2) Decodes them (to determine type and operands) 3) Executes them This is repeated for subsequent instructions
What does each process have?
An associated address space containing executable program, its data and its stack
How do processes work in multiprogramming?
Each process has its own logical program counter (there is only one physical program counter), so when a process runs its logical program counter is loaded into the physical program counter.
What events cause processes to be created?
1) System initialisation
2) Execution of a process creation system call by a running process
3) A user request to create a new process
4) Initiation of a batch job
How are processes that are not created at boot created?
They must be created by other processes issuing system calls to create processes to help out
CreateProcess
Windows call that both creates a new process and loads correct program
How does a process terminate and are these voluntary or involuntary?
1) Normal exit (voluntary) 2) Error exit (voluntary) 3) Fatal error exit (involuntary) 4) Killed by another process (involuntary)
Give an example of a fatal error
Seg fault Divide by 0 error Bus error
How many parents does a process have?
1, but may have 0-many children
How are signals sent to a process group?
Signals are sent to all members of an associated process group. Each process can choose to catch, ignore or take the default action (be killed) with regard to the signal
What is the default action of a process when receiving a signal?
To be killed
Explain the concept of process hierarchy in Windows
There is no concept of process hierarchy in Windows. All processes are created equal. The parent process is however given a token called a handle, which can be used to control the child process. However, this can be passed to other processes, invalidating the hierarchy.
Can parent processes in UNIX disinherit their children?
No
All processes in a system belong to what?
A single tree (inheritance) with init at the root
Explain the concept of process hierarchy in UNIX
Association exists between parent and child processes. A process and all of its descendants form a process group
How does init work?
This is present in the boot image. It reads in a file with the number of terminals and forks off one process per terminal. These terminals wait for a user to login. If successful, login process executes a shell to accept commands, including starting more processes
How many processes does a program running twice count as?
2
How does a process run a new program?
The process forks off a child process, which executes execve to change memory image and run a new program. By doing this, the child can change file descriptors between the new program and the execve to achieve redirection of standard input, output and error.
Are background processes associated with particular users?
No
Why shouldn’t programs be built with assumptions about timing?
Multiprogramming will cause inconsistencies in this if programs are temporarily stopped to let others run
What states can a process exist in?
1) Running: currently using CPU 2) Ready: ready to run, but waiting on another process currently using CPU 3) Blocked: unable to run until some external event happens
What are the transitions between the states that a process can exist in?
1) Running to Blocked: Process realises that it is dependent on some external information in order to continue execution 2) Running to Ready: Caused by scheduler deciding to allocate time to another process 3) Ready to Running: Caused by scheduler allocating time to this process 4) Blocked to Ready: External event occurs meaning that process is able to logically run. If no process is running, transition 3 will be automatically triggered
What states can a thread exist in?
1) Ready 2) Running 3) Blocked (same as process)
Why is there no protection between threads?
1) Not possible 2) Shouldn’t be necessary: a process is always owned by a single user and threads should be made to cooperate
