Operating Systems test 1 Flashcards

1
Q

What comprises a process?

A

Memory (address space): Instructions, Data section
Registers: Program counter, Stack pointer
I/O information: List of currently open files

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

What happens upon process creation?

A

A new process is created with a unique process ID.
The process gets allocated memory and system resources.
Initial values are set in the memory, registers, and I/O info.

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

What are the process states and their corresponding data structures?

A

Running: The process is currently executing.
Ready: The process is ready to execute but waiting for CPU time.
Blocked: The process is waiting for some event or resource.
PCB (Process Control Block): A data structure that stores process state information, memory allocation, and more.

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

What system calls are involved in process creation?

A

fork(): Creates a new process by duplicating the parent process.
exec(): Replaces the current process’s memory with a new program.
wait(): Makes the parent process wait for the child process to finish.

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

How is a child process created? What does it get from the parent process?

A

A child process duplicates the parent process (memory, registers, etc.) using fork().
The child gets the same address space, but it has a different process ID.

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

What is I/O redirection and pipe?

A

I/O Redirection: Redirects input/output streams from the default (keyboard, screen) to files or other processes.
Pipe: Allows the output of one process to be used as the input for another process

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

What is CPU virtualization and limited direct execution?

A

CPU virtualization involves providing an abstract view of the CPU to processes.
Limited direct execution allows processes to execute directly on the CPU but with certain restrictions to ensure security and fairness

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

What is the difference between user mode and kernel mode?

A

User mode is for executing user applications with limited privileges.
Kernel mode is for executing privileged system operations with full access to hardware.

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

What is a system call and trap instruction?

A

System call is a request from user space for services provided by the kernel.
Trap instruction is a mechanism to transition from user mode to kernel mode when invoking system calls.

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

What is the trap table (interrupt vector)?

A

The trap table is a lookup table for handling system calls or interrupts.
The interrupt vector is the specific memory address for each trap.

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

What is a context switch?

A

A context switch is the process of saving the state of a running process and loading the state of the next process to be executed.

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

What are the metrics used for scheduling? (turnaround time, response time)

A

Turnaround time is the total time from the submission of a process to its completion.
Response time is the time from submitting a request until the first response is produced.

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

What are the scheduling algorithms? (FIFO, SJF, STCF, RR)

A

FIFO (First In, First Out): Processes are scheduled in the order they arrive.
SJF (Shortest Job First): The process with the shortest execution time is scheduled first.
STCF (Shortest Time to Completion First): A preemptive version of SJF.
RR (Round Robin): Each process gets a fixed time slice, then the CPU moves to the next process.

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

What is MLFQ and its drawbacks?

A

MLFQ (Multi-Level Feedback Queue): A scheduling algorithm that adjusts the priority of a process based on its behavior.
Drawbacks: It can lead to starvation and excessive context switching if not properly tuned.

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

What is a proportional share scheduler?

A

A proportional share scheduler allocates resources to processes based on their assigned share of CPU time.

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

What is virtual memory?

A

Virtual memory is an abstraction of the physical memory, allowing processes to use more memory than physically available.

17
Q

Where do different types of data go in a process’s address space?

A

Code: Contains program instructions.
Data: Holds global variables and static variables.
Stack: Used for local variables and function calls.
Heap: Used for dynamic memory allocation.

18
Q

How do you calculate the address space size for a 32-bit address?

A

The address space size for a 32-bit address is 4GB (2^32 bytes).

19
Q

What is the purpose of malloc() and free()?

A

malloc(): Allocates memory on the heap.
free(): Frees memory previously allocated by malloc().

20
Q

How does address translation work from virtual to physical address?

A

Address translation maps a virtual address to a physical address in memory using a page table.

21
Q

What is the basic method for address translation?

A

Base and bound registers map virtual addresses to physical addresses, ensuring that the process’s memory stays within its allocated region

22
Q

What is the problem with mapping a contiguous block of physical memory to the entire virtual address space?

A

Internal fragmentation occurs because physical memory might not be used efficiently

23
Q

What is segmentation and its issue?

A

Segmentation divides memory into variable-sized segments to solve internal fragmentation.
External fragmentation can occur as free space gets scattered.

24
Q

How does paging solve external fragmentation?

A

Paging divides memory into fixed-size blocks (pages) and eliminates external fragmentation by allowing non-contiguous allocation.

25
Q

What is TLB and how does it help with address translation?

A

TLB (Translation Lookaside Buffer) is a cache that stores recently used page table entries, reducing the time overhead in address translation.

26
Q

What is temporal and spatial locality?

A

Temporal locality: If data is accessed once, it’s likely to be accessed again soon.
Spatial locality: If data is accessed at one memory location, nearby locations are likely to be accessed soon.

27
Q

What are multi-level page tables?

A

Multi-level page tables break the page table into smaller tables to reduce space overhead for large address spaces.

28
Q

How do you calculate the number of bits for virtual page numbers in a single-level page table?

A

Number of bits for virtual page number = log2(number of virtual pages).

29
Q

How do you calculate bits in a two-level page table?

A

Bits for page directory index: Determines which entry in the page directory points to the page table.
Bits for second-level page table index: Determines the specific page in the second-level page table.
Bits for offset: Specifies the location of data within a page.