OS Flashcards

1
Q

What does an OS do?

A

An operating system creates a level of abstraction between hardware and software. It helps in process management, memory management and Input/Output devices.

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

How did the first operating systems work?

A

The first operating system(OS) only had a library of subroutines to function. Also, the OS could not run multiple programs at once. Lastly, the OS could read/write all the memory disk which meant no protection.

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

What did multiprogramming mean for first OS?

A

Multiprogramming enables multiple programs to run at once which means the CPU utilization is maximized and processes needs to be protected from each other. This gave rise to the UNIX OS.

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

What are the modern operating systems?

A

Support multiprogramming, provides access to diverse hard-ware and has built-in network support.

Modern OS are all implementations of the UNIX OS.

MacOS-BSD of UNIX

LINUX-Reimplementation of UNIX

Windows- heavily influenced by UNIX

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

What are the goals of an operating system?

.

A

The main goal of an operation system is its ease of use due to the level of abstraction between hardware and software.

For the end users, it creates a consistent user interface, manage multiple application simultaneously, and the OS can also prevent users to run malicious or buggy code.

As for the programmers, it provides a consistent programming interface(library subroutines via O/S), provides access to hardware and I/O devices and manages system resources(memory, files, network)

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

What is an abstraction? How are OS’s abstracted?

A

Abstraction is hiding the level of complexity to the users by providing a clean user interface.

Operating systems are virtualized by creating a virtual form of each physical resources(CPU, memory, disk) for each process(processes, address memory, files). Virtualization creates an illusion that the entire block of CPU is for itself/ entire block memory for itself.

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

What is the micro and macro kernel?

A

Micro kernel is the CPU , Memory , Devices while macro is the core.

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

How can multiple programs run same time?

A

Timesharing enables the OS kernel to periodically switch between processes and if done fast enough, it can create the illusion of concurrency. Works for both end users and programmers.

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

How are processes managed?

A

A process can be managed through three states i.e running, ready and blocked state.

The process is firstly created when the code is run into memory, and is in the ready state.

When the process is scheduled, it moves to the running state and back to ready if needed to be descheduled.

If an I/O device needs to be accessed by the running process, it goes to the blocked state until the I/O is complete which is when it moves back to the ready state for the cycle to continue.

Lastly, if the process if fully done, it can be terminated.

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

Challenges of CPU needing hardware?

.

A

It should not create huge overhead

It needs to stay in control.

Needs to be protected against buggy or malicious code.

Enable fair time sharing.

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

What is Limited Direct Execution?

A

Application code is running directly on the CPU. The OS does not run at this time. This problem is solved with limited direct execution.

By limiting what programs can do without affecting performance, the CPU has two different modes- User mode and kernel mode.

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

What is the user mode and kernel mode?

A

The CPU has two modes. In the kernel mode, the code run has no restrictions.

The operating system runs on kernel mode.

An interrupt triggers a switch into kernel mode.

Meanwhile, the user mode can only run a limited number of instructions, I/O instructions are not allowed at all. Normal applications runs in user mode.

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

How can the user-mode of the CPU access Input/Output devices?

A

They can be accessed through system calls

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

What are system calls?

.

.

A

System calls are special instructions that expose the OS functionality to the user mode. For e.g→ system calls to access network interface, file I/O, other processes,allocate memory, etc.

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

How does the system call work?

A

Operating system has a table of system call handlers. When a process makes a system call with number n→

Save its process context(current state in registers etc) into memory

Switch CPU into kernel mode

Jumps to system handler n.

Restores the process context

Switch CPU to user mode

Return to calling process.

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

How do you implement system calls?

A

To implement system calls, an instruction needs to be added to cause an interrupt, also called as software interrupt. Interrupt caused because of instruction execution in CPU.

17
Q

What is process switching?

A

Helps the OS to regain control of the process as when user mode executes, kernel mode doesnt but can due to system calls where it jumps to the kernel mode. Switches processes. It returns to a different process.

18
Q

What are the two types of process switching?

A

Cooperative Scheduling(Non-preemptive) - switches into kernel mode when user makes a system call or when hardware is interrupted.

Processes cannot be scheduled.

The operating system initiates a context switch between two processes.

They are easy to implement however what if the program doesnt cooperate? E.g→There could be an infinite loop with no system calls.

Preemptive Scheduling- Waits for a timer interrupt i.e processes are preemeptive and can be scheduled.

The OS will initiate a context switch from one process to another.

19
Q

When does the OS gain control in process switching?

A

In cooperative scheduling, the OS only gains control when the user mode has a system call. The OS checks whether the process needs to be switched.

If no, the OS handles the system call and returns to running state

If yes, the OS puts the current program into ready state while other processes change to running state.

Meanwhile in preemptive scheduling, timer is implemented in a special hardware running every 10 milliseconds. The interrupt switches into kernel mode and executes interrupt handler. The OS can go to a different process as interrupt handlers are part of the OS.

→The OS gains control at regular intervals

20
Q

When do we switch processes?(preemptive)

A

There can be goals to switch processes, could be either checking for the turnaround time or fairness.

Turnaround time→ Poor turnaround- First Come First Served.

Good turnaround- Shortest Job First

Fairness→ Allocate time slices for each process in a round robin fashion.

The shorter the time slice, the fairer the schedule.

However, a context switch may take time. The scheduling needs a right compromise

Modern OSs use a form of round-robin scheduling

21
Q

What are the issues with turnaround time?

A

Would work well if there was a known time for each process before running and processes are ready to run at the same time.

However, there is not a known time and some processes never stop runnning.

22
Q

What is the mechanism of virtual memory?

A

Under virtual memory, each process can only process its own memory with its own address space. This means that although every process has a fixed block of memory, the process starts from memory address 0 as if it had the entire memory to itself. This ensure protection of OS/ Hardware. This works as the virtual memory is translated to physical memory address space by the OS/Hardware while programmers code virtual memory as if address was from 0.

It takes memory from the hard disk for virtual memory.

23
Q

How does virtual memory get abstracted in a simple approach?What are its issues and how to solve them?

A

A new register is added called ‘Base register’ where when processes switch, the base address of the physical memory X is added into the base register B containing the virtual address Y.

The process, although, cant access any memory address lower than register B. Also, there is no limit to what it can access. A possible solution would be add a maximum bound where the process can access memory address between B and bound. If it is not in the range, it will raise an interrupt to the OS

Although it is still quite limited as the process gets a fixed block and there is no way to enlarge or decrease.

24
Q

What is the modern approach of virtual memory?

A

The modern approach lets OS and hardware divide the virtual memory into chunks called pages. Processes can access a set of pages where it can be added or removed. As a result, the physical address can dynamically be mapped into process address space

25
Q

How is virtual memory created?

A

Firstly, the RAM has limited space for storage(8 gb). Therefore, the unused pages are moved into external storage. When a process tries to access an unavailable page, the hardware will cause an interrupt called a page fault. The OS handles the interrupt and can load the page back for use from external storage, while swapping it for another unused page.This mechanism works well if the swapping is not too frequent.