is “reading from disk” an example of an abstraction the os provides?
Yes! it is machine independent, easier and hiding unnecessary details
name what relates to user-mode,kernel mode and hardware: editors, system calls, compilers, shell, process management, I/O, file system, disks, CPU. In addition, why the operating system is named also an “extended machine”?
User interface(shell, editors,compilers,etc) is where users can program. they ask the kernel for info using the library interface(open,close, fork, etc). the library interface is using the system call interface in order to move into “kernel mode” where we have UNIX operating system(process management, memory management, the file system, I/O, etc). the kernel mode then reads/writes the information from/to the Hardware(CPU,memory, disks, terminals, etc..) The OS is referred to as an “extended machine” because right from the hardware it gets extended to “kernel mode” and then to “user mode”
“Recipe”, “Baker”,”Ingredients”, “Baking the pie”. who is the process, program,processor and data?
Recipe = Program Baker = Processor Ingredients = data Baking the pie = Process
What are the goals of the OS regarding processes?
when is a new process created?
when does a process terminate?
what are the process states?
Running - using the CPU Runnable - temporarily stopped to let another process use the CPU Blocked - unable to run until some external(!) event happens.
can a process block itself? or run itself?
it can block itself, setting its state field to BLOCKED but it can’t run itself because the scheduler skips it as long it is in blocked state.
For what reason does a process become blocked?
Scheduling: what is a single Blocked Queue?
the scheduler holds a “Ready Queue” for process that are ready to be executed. in addition it holds a “blocked queue” for processes that are waiting for some event.
Scheduling: what is a multiple Blocked Queue?
same idea as “Single Blocked Queue” just that here each blocked process is placed in a specific event queue.
what is a suspended process?
A process which has been moved from memory to disk
why is a context switch called a context switch?
because the processor operates in terms of context - registers, program counter, etc. when we switch processes we switch contexts
what happens in a context switch?
what does “fork” do?
it duplicate a process for a given program to create a new process, to perform other tasks: 1. parent check if process table is full, if not - it allocates a spot for the child 2. parent tries to allocate memory to child’s data and stack. 3. parent copies its code, data and stack to the child’s memory. 4. parent sets eax register of child to 0, so the “fork()” call returns 0 for the child 5. return pid of child.
what is exec for?
executing a new program; the program code is loaded to the process’ image: 1. fork() creates a new process 2. execvp replaces the process core image with that of another executable program
from shell(sh), which system calls occur in order to exec “ls”?
What is a signal? how is it generated?
It is a software interrupt. they are generated via: 1. keyboard - ctrl-C, ctrl-Z 2. kill syscall 3. command line - kill
who can a process send signals to?
To all process within its “process group”
What can a process do once receiving a signal?
How defining a signal behavior is done?
by calling: signal(signum, [function|SIG_IGN,SIG_DFL])
how does a process receive a signal?
the kernel sets signal bits in the process struct upon receiving signals.
when is a “sigabrt” signal(core dump) received?
When there’s fault occurred in the program - usually due to an invalid pointer value(it is likely you are using an uninitialized pointer).
when is a “sigalrm” signal(alarm clock) received?
when sleep was called and time is up.