OS - Processes Flashcards

1
Q

is “reading from disk” an example of an abstraction the os provides?

A

Yes! it is machine independent, easier and hiding unnecessary details

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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”?

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

“Recipe”, “Baker”,”Ingredients”, “Baking the pie”. who is the process, program,processor and data?

A

Recipe = Program Baker = Processor Ingredients = data Baking the pie = Process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the goals of the OS regarding processes?

A
  1. interleave processes executions to maximize processor utilization 2. provide reasonable response time 3. allocate resources to processes. 4. support inter-process communication and synchronization.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

when is a new process created?

A
  1. System initialization(userinit) 2. Exec 3. fork 4. batch job(?)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

when does a process terminate?

A
  1. normal exit (voluntary) 2. error exit (voluntary) 3. fatal exit (involuntary) 4. killed by another process (involuntary)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are the process states?

A

Running - using the CPU Runnable - temporarily stopped to let another process use the CPU Blocked - unable to run until some external(!) event happens.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

can a process block itself? or run itself?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

For what reason does a process become blocked?

A
  1. waits for some event(other process to end its job, etc) 2. waits for input from the kernel.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Scheduling: what is a single Blocked Queue?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Scheduling: what is a multiple Blocked Queue?

A

same idea as “Single Blocked Queue” just that here each blocked process is placed in a specific event queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is a suspended process?

A

A process which has been moved from memory to disk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

why is a context switch called a context switch?

A

because the processor operates in terms of context - registers, program counter, etc. when we switch processes we switch contexts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what happens in a context switch?

A
  1. 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does “fork” do?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is exec for?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

from shell(sh), which system calls occur in order to exec “ls”?

A
  1. fork() - create more process of sh 2. exec(“ls”,args) - use the new process for the new program - ls.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a signal? how is it generated?

A

It is a software interrupt. they are generated via: 1. keyboard - ctrl-C, ctrl-Z 2. kill syscall 3. command line - kill

19
Q

who can a process send signals to?

A

To all process within its “process group”

20
Q

What can a process do once receiving a signal?

A
  1. ignore it - not always 2. let the system take default action 3. catch it by process’ signal header
21
Q

How defining a signal behavior is done?

A

by calling: signal(signum, [function|SIG_IGN,SIG_DFL])

22
Q

how does a process receive a signal?

A

the kernel sets signal bits in the process struct upon receiving signals.

23
Q

when is a “sigabrt” signal(core dump) received?

A

When there’s fault occurred in the program - usually due to an invalid pointer value(it is likely you are using an uninitialized pointer).

24
Q

when is a “sigalrm” signal(alarm clock) received?

A

when sleep was called and time is up.

25
Q

when is a “sigsegv” signal(segmentation fault) received?

A

Accessing memory that “does not belong to you”. that is, you are doing something wrong with memory - accessing memory that has already been freed, writing to a read-only portion of the memory, dereference a null pointer, dereference a pointer that ceased to exist(maybe was removed by the garbage collector) etc.

26
Q

when is a “sigill” signal(illegal instruction) received?

A

when an attempt is made to execute an invalid, privileged, or ill-formed instruction

27
Q

when does SIGCHILD is sent to parent?

A

upon child process termination

28
Q

what happens if the parent terminates before the child?

A

the child is passed to the init process

29
Q

what’s the name for a terminated child process for which its parent didn’t call wait()

A

A zombie! because it doesn’t get clean by the kernel via “wait()” system call which is called by the parent. that is, it still holds a process table entry.

30
Q

what does a process control block hold? and what from that is moved to the Thread control block?

A

PCB: code, data, files, registers, user stack and kernel stack. TCB: registers, user stack and kernel stack.

31
Q

what are the fields of a thread struct?

A

context trapframe kstack state

32
Q

Why is a thread the basic unit for the CPU?

A

Because it holds all that CPU needs for running commands: program counter; register set; stack space

33
Q

What are the benefits of threads?

A
  1. less time to create(vs process) 2. less time to terminate 3. less time to switch between threads within the same process 4. threads within the same process share memory and files -> they can communicate without invoking the kernel!
34
Q

Does suspending a process means suspending all of its threads?

A

of course! all threads share the same PTE .

35
Q

In a thread based system, what happens if fork() is called?

A

Only thread calling fork is duplicated.

36
Q

what are the difference between User-Level Threads to Kernel Level Threads?

A

User-Level Threads: all management is done by the user. that is, the kernel is not aware of the existence of threads.

37
Q

Advantages of User-Level-Threads

A

Thread switching does not require kernel mode privileges (faster) and the scheduler can be user specific(can be more efficient)

38
Q

Disadvantages of User-Level-Threads

A
  1. A system call by a thread blocks the process. that means that if one threads reads from disk - all other threads are blocked. 2. Page fault - all other threads are blocked! 3. Time limit - cannot handle clock interrupts per thread. 4. stack growth fault - kernel is not aware of which thread’s stack caused the fault.
39
Q

Kernel-Level Threads. How does it work?

A
  1. kernel maintains context information for the process and the threads. 2. kernel can schedule different threads of the same process to different processors. 3. switching between threads requires the kernel
40
Q

What is the gain of using a multi-core?

A

Pipelining permits instruction-level parallelism. Multi-core permits both ILP and Thread-Level-Parallelism on same CPU.

41
Q

What is a hardware threads?

A

It is an hardware in the core which appears to the OS as a logical processor and if the scheduler is aware of HW threads it would be much more efficient. The core stores more registers and logic for much faster thread context switch. For instance, some chips contain 8 cores, each comprising 8 HW cores for a total of 64 concurrent threads!

42
Q

A system call can be roughly grouped into five major categories. What are they?

A
  • Process control
  • File management(read/write)
  • Device management(attach a device)
  • Information maintainance(set time or date)
  • Communications(send messages)
43
Q

What is a trapframe

A

A backup of the process’ current execution state.