1an abrupt change in control flow in response to some change in the processors state
Interrupt
21. Original program processes
2. Event occurs
3. An indirect procedure call is made through the jump table to an operating system subroutine (interrupt handler)
4. interrupt returns
Steps of an interrupt
3Operating system subroutine that deals with interrupts (like a function)
Interrupt Handler
4an array of indexes corresponding to addresses to interrupt handlers created at system boot, AKA exception table
Jump table
51. Interrupt returns to the old process and moves on
2. returns to instruction that was trying to execute before the interrupt, retries it
3. returns and moves on to a completely different program (essentially terminating the original program)
What are the 3 ways to return from an interrupt?
6Divide by zero or segmentation fault, any hardware issue
Hardware interrupts
7Service calls, anything OS related
Operating system interrupts
8-return address is a far address so it can return with a intersegment jump
-allows jump from kernel to process
-processor saves the program status in a word
- runs in kernel with an elevated privilage
Interrupt characteristics
9Often these happen not at the same time, triggered by I/O devices like the keyboard
Device interrupt
10Intentional exceptions that occur as the result of executing instruction, if the handler corrects it will return to the faulty instruction and retry, ex: page fault
Fault
11When a virtual address is referenced that doesnt have a page on memory. (it has to be retrieved from disk)
Page fault
12Traps are wrapped up into functions like read(), open(), and write()
Linux system calls
13Instance of a program in execution, They have an independent logical control flow and private address space
Process
14Two flows whose execution overlap in time.
Concurrency
15a process taking turns with other processes
multitasking
16two processes on different processors running at the same time
Parallelism
17The OS sets up mappings between a processes logical memory and RAM, Processes only see memory through mapping
Logical memory
18What library are fork and execve in
unistd
19Clones the process, it's file descriptors, it's process group ID, it's memory space, pretty much everything
Fork
20When fork returns 0
child
21when fork returns the childs process ID
Parent
22An unreaped child (when the parent doesn't use wait())
Zombie
23Allows to child to see it's own process ID
getpid()
24Waits for any child to end - Non-deterministic
wait()
25waits for a specific child to end
waitpid()
26What do you include to use wait
#include <sys/wait.h>
27Path, arguments, null terminator
Argv
28replaces code with an execution of a command line statement
execve(argv[0],argv, 0)
29higher level software form of exceptions that allow processes + kernel to interrupt other processes,
allows processes to catch interrupts
signals
30kernel forces destination process to react to signal
ignore, terminate, or handle it with a user level function
recieving signals
31sent but not recieved, only one can exist for each type of signal
pending signals
32processes can block the reciept. they are delievered but no response
blocking signals
33How do you get the process group of which the child and parent are the same
getpgrp()
34in/kill -9 15213
in/kill -SIGKILL 15213
in/kill -KILL 15213
command line kill
35kill(pid, SIGKILL)
kill system call