OS - Processes Flashcards
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?
- interleave processes executions to maximize processor utilization 2. provide reasonable response time 3. allocate resources to processes. 4. support inter-process communication and synchronization.
when is a new process created?
- System initialization(userinit) 2. Exec 3. fork 4. batch job(?)
when does a process terminate?
- normal exit (voluntary) 2. error exit (voluntary) 3. fatal exit (involuntary) 4. killed by another process (involuntary)
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?
- waits for some event(other process to end its job, etc) 2. waits for input from the kernel.
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?
- we save the processor context and save it one the old process struct. 2. update old process state 3. move old process to appropriate queue. 4. select another process for execution(remove from queue) 5. update new process state 6. restore new process context
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”?
- fork() - create more process of sh 2. exec(“ls”,args) - use the new process for the new program - ls.