CSE 3430 – C1-C3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

encourage image

There's no tags or description

Looks like no tags are added yet.

30 Terms

1
New cards

What is the operating system (OS)?

The operating system is a special program that sits between users/applications and raw hardware. It turns hardware into something applications can use and makes sure the whole system runs correctly and efficiently

2
New cards

What are the two roles the operating system takes on to do its job?

  1. Translator – The OS simplifies complicated hardware through abstraction. The programs never touch the CPU directly – they run as processes. They don’t deal with raw memory chips – they get their own neat address space. They don’t deal with storage – they see files and folders

  2. Referee – The OS divides up resources and allocates them efficiently & fairly among programs. It also protects programs from each other so one crashing app can’t wreck another.


3
New cards

What are the three problems that every modern OS faces?

  • Virtualization – the art of illusion and making each program believe it has the whole machine to itself

  • Concurrency – the problem of many things happening at once and giving overlapping programs tools (i.e locks & semaphores) to hide their chaos from eachother

  • Persistence – the problem of remembering data despite reboots, crashes, and power cuts


4
New cards

In the earliest days, a computer ran one program at a time. This is called:

Uniprogamming

5
New cards

Now, every OS can run many programs at once. This is called:

Multiprogramming

6
New cards

What is the idea that OS designers use to manage the downsides of multiprogramming (which includes difficulty managing the OS machine’s resources)?

The Process

7
New cards

What is a process? (In relation to a program)

A program is lifeless code and data sitting on a disk.

A process is that program running: It is a live copy of the progam’s code and data in memory.

8
New cards

What is the formal definition of a process

An execution stream together with its execution state

9
New cards

Why do processes matter?

They allow the OS to pause a running program in the middle and resume it later. This gives the OS the flexibility to share the machine well.

10
New cards

What are the three basic actions on processes

  1. Create

  2. Destroy

  3. Wait (wait for another process to finish)


11
New cards

What are the 4 steps the OS takes to create a process?

  1. It copies the program’s code and static data from disk into memory

  2. It sets aside space for a stack

  3. It sets aside space for a heap

  4. It sets up I/O.
    - In Unix/Linux, every process starts with three open files: stdin, stdout, and stderr


<ol><li><p>It copies the program’s code and static data from disk into memory</p></li><li><p>It sets aside space for a stack</p></li><li><p>It sets aside space for a heap</p></li><li><p>It sets up I/O. <br>- In Unix/Linux, every process starts with three open files: <code>stdin, stdout, and stderr</code></p></li></ol><p></p>
12
New cards

What are the three states of life for a process?

  1. Running – it’s executing instructions on the CPU

  2. Ready – it has everything it needs and is waiting for the CPU

  3. Blocked – it’s waiting for some event (i.e disk transfer finishing or a lock becoming free)


13
New cards

What are the two ways resources can be shared during virtualization?

  1. Time-sharing – processes take turns and only one uses the resource at a time (this is how the CPU is shared)

  2. Space-sharing – each process gets a slice of the resource (this is how memory and disk are shared)


14
New cards

What is direct execution and its 3 problems?

Direct execution: let the process run straight on the hardware. The OS sets it up, jumps to main(), and steps aside.

Problem 1: Process could do something forbidden

Problem 2: Process could run forever and the OS would never get the CPU back

Problem 3: Process could do something slow and waste the CPU while it waits

15
New cards

Solution of direct execution

Limited direct execution – Processes run directly on the hardware, but the OS and hardware keep control at key moments

16
New cards

How does Limited Direct Execution fix Problem 1 of Direct Execution (Process could do something forbidden)

The hardware has a mode bit with 2 modes:

  • User Mode (where user processes run)

  • Kernel Mode (where the OS runs)

Some instructions are only allowed in kernel mode. if a user process tries one, the process is terminated.

17
New cards

What happens when a process legitimately needs to be in kernel mode?

  • The process makes a system call (a request for the OS to do the work)

  • The system call uses a trap to switch into kernel mode


18
New cards

How does kernel return to user mode?

The kernel sets the mode bit back and loads the process’s next instruction address into the PC. It does both in a single instruction.

19
New cards

How does Limited Direct Execution fix Problem 2 of Direct Execution (a process could run forever)

The hardware has a timer interrupt that fires on a regular schedule, and user processes can’t disable it.

Each interrupt hands the CPU back to the OS.

The OS’s dispatcher can then stop the running process, save its registers in its PCB, and context-switch to another process.

This is called forced multitasking.

20
New cards

How does Limited Direct Execution fix Problem 3 of Direct Execution (a process could waste the CPU on slow operations)

When a process starts a slow operation, the OS marks it blocked and puts it in the queue for that event.

The CPU goes to a ready process from the ready queue.

When the event finishes, the blocked process moves back to ready and waits its turn.

21
New cards

What is a Scheduler?

The OS policy that looks at the ready queue and decides which process gets the CPU next, and for how long.

Then, the dispatcher actually performs the switch.

22
New cards

Turnaround time vs. response time

Turnaround time is how long until a job finishes (completion – arrival)

Response time is how long until a job first runs (first run – arrival)

23
New cards

Preemptive vs non-preemptive

A non-preemptive scheduler lets a job keep the CPU until it gives it up (by doing I/O or calling exit).

A preemptive scheduler can take the CPU away from a running job at any time.

24
New cards

FIFO / FCFS (First In, First Out / First Come, First Served)

Runs jobs in the order they arrive. It's simple and works well when jobs are the same length. Its weakness is the convoy effect (short jobs get stuck behind long ones)

25
New cards

SJF (Shortest Jobs First)

Always runs the job with the shortest run time. Fixes FIFO’s convoy effect. Its weakness is that it’s non-preemptive, so short jobs that arrive while a long job is running still have to wait.

26
New cards

STCF (Shortest Time-to-Completion First)

A preemptive version of SJF that always runs the job closest to finishing. This fixes SJF’s late-arrival problem by pausing a long job when a shorter one arrives.

Its weakness is that it needs to know run times in advance.

27
New cards

RR (Round Robin)

Gives each ready job a fixed time slice (time quantum) in turn. This fixes the poor response time of FIFO, SJF and STCF, and it doesn't need to know run times.

Its weakness is worse turnaround time (jobs take longer to finish)

28
New cards

MLFQ (Multi-Level Feedback Queue)

Learns from each job’s past behavior, so it works without knowing run times. It’s closest to what real systems use.

29
New cards

MLFQ Rules

  • Higher-priority queues run first.

  • Jobs at the same level share the CPU in round robin.

  • New jobs start at the top.

  • A job that uses its whole time slice is demoted one level.


30
New cards

MLFQ’s Two Problems & The Priority Boost

  1. Starvation: low-priority jobs may never run if higher queues stay busy.

  2. Inflexibility: a job that starts as batch but becomes interactive stays stuck at a low priority.

  • Priority Boost: periodically boost all jobs back to the top priority