OS midterm Flashcards

1
Q

4 sources of processor interrupts?

A

Device Interrupts: signal from controller that says it needs attention
I/O Events: arrival of new info
Timer
Program Errors

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

Where is the state of an interrupted process saved?

A

Pushed onto Control Stack

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

What is locality of reference?

A

Programs tend to remain in certain regions before moving to new ones

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

What are the two examples of locality of reference discussed in class?

A

If a program executes instruction i, it is likely to execute i+1 next
Programs may iterate over a block of data in a loop, which uses the program and the data mostly

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

How does locality of reference make cache memory effective

A

If the processor hardware can move the referenced blocks of memory from main
memory into cache memory when the block is first accessed, instructions and/or
data will be found in cache (hit) for all the remaining access while in a region and
the overall execution of the program / process will be that much faster.

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

What are the restrictions on User Mode compared to Kernel Mode?

A

Can only access allotted memory
Can’t run privileged instructions

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

What causes the OS to switch into Kernel mode from User Mode?

A

Any interrupt

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

What is the name of the mechanism to request resources or a service from the OS?

A

Syscall

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

What are the four steps involved in making a syscall?

A
  1. Place the Syscall number and arguments in specified registers
  2. Send a software interrupt. This saves the current processes’ state on the stack
  3. Interrupt handler looks at the registers and executes the request
  4. When finished, restore state using IRET instruction and return to user mode
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the four innovations of computer systems design that make modern OS possible? Name and describe

A
  1. Protected memory: Kernel operates in a region of memory that can only be accessed in kernel mode
  2. Privileged Instructions: instructions that can only be executed by the processor when it is in kernel mode. 1 and 2 are made to prevent corruption of the OS while running (or stealing protected data)
  3. Interrupts: Way to interrupt/pause currently running program to handle asynchronous events
  4. Hardware Timers: periodic interrupts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What info is maintained in the process image?

A

The process image is the region of memory (disk or main memory) containing
the instructions / data / stack of the program being executed.

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

In what 2 places is the process image stored?

A

System Drive (as a file) and Main Memory

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

What are the 5 steps to create a process image?

A
  1. Allocate space for the new image on the system (swap) drive. Copy the text and data segments from the executable file to the new image
  2. Create PCB and other resources needed for process execution
  3. Assign unique PID to process
  4. Copy image from the system drive into main memory
  5. Put the process in the ready state and put it into the Ready queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Purpose of the PCB?

A

Process Control Block: used to maintain info needed to maintain a single process. Maintained by the kernel

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

What are the 3 categories of info stored in the PCB? Name and explain.

A

Process Identification: Information to identify the process. PID, PPID, Owning user ID, etc.
Process Control:
Processor state: State of the processor needed to allow the process to be context switched. Aka the state to be restored when process resumes

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

Differences between the PCB in a single-threaded process vs. the PCB/Thread Control Block in a multithreaded process

A

Since a STP only has one thread, there is very little distinction between the thread control and the process control. In a MTP, though, these are separate because while the process only has one PCB, it may have many thread control blocks.

17
Q

What are the differences between how the user-mode stacks are maintained in a STP vs. an MTP

A

There is one user-mode stack per thread, so an STP only has one but a MTP has one per thread

18
Q

What are the differences between how processor state information is maintained in a STP vs. an MTP

A

This is stored in the Thread Control Block. So in a STP this is in the PCB and in a MTP this is in the Thread Control Block

19
Q

What are the differences between how OS resources are managed in a STP vs. an MTP

A

No differences, both are maintained at the process level

20
Q

3 advantages of threads over processes

A
  1. Threads can be created/destroyed quicker
  2. N threads require less memory than N processes
  3. Efficient communication between threads through memory owned by the process
21
Q

3 Multithreading control strategies?

A

Worker Threads: Many threads take items from a FIFO and work them independently
Task Scheduling: Task(s) are periodically run. On a loop, run, then wait.
Event Handling: Events are delivered to system from many sources. Event handlers for each source can be in their own thread. Example is socket.read which is blocking

22
Q

What are the 3 advantages semaphores offer over compare and swap instructions

A
  1. Semaphores cause the blocking of waiting processes / threads eliminating the
    busy-wait loop utilized by C&S instructions.
  2. Semaphores offer the fair scheduling of blocked processes using FIFO queue
    of processes / treads waiting on the semaphore i.e. no starvation of waiting
    processes / threads.
  3. With C&S, if the process in the critical section dies before setting the shared
    variable to zero, the waiting processes will never unblock. Because a
    Semaphore is managed by the OS, if the owning process dies while in a CS,
    the OS will release the terminated process’s ownership on any semaphores
    allowing waiting blocked processes to continue.

tldr:
1. no busy-wait loop spinning
2. fair scheduling of blocked processes
3. waiting processes will unblock if owning process dies

23
Q

How do semaphores use a FIFO queue

A

They use it to keep track of the blocked threads waiting for it. The first one to request will be the first one to get it