classnotes RTX 4070 Ti SUPER · faster-whisper · DeepSeek

5102 - Foundations of Comp Sys

← 5102 - Foundations of Comp Sys

FCS_11 Oct

Date 2026-10-11 Length 3h 07m Words 16,176 Segments 1,947
⤓ Download transcript (.txt with timestamps) ⤓ Plain transcript (.txt) ⤓ Transcript (.md)

Summary


session: "5102-foundations-of-comp-sys/2026-10-11 0000 FCS 11 Oct"

title: "FCS 11 Oct"

date: "2026-10-11 00:00"

duration: "3h 06m"

language: "en"

model: "deepseek-ai/DeepSeek-V4.1-Flash-1017"

parts: 4

transcript_chars: 89386

generated: "2026-11-23T15:56:03+05:30"


FCS 11 Oct

Overview

This class covers CPU scheduling and threads: how the OS decides which ready task runs on a core, and the cost and mechanics of switching between them. It builds from the system-call → process → thread chain, through concurrency vs. parallelism and context switching, into the classic scheduling algorithms (FCFS, SJF, SRTF, priority, round robin) with worked numeric examples. The second half extends into aging, starvation, deadlock, and fair/proportional-share scheduling, illustrated with a weighted quotes-vs-logs example and live Linux thread observations. It sits at the OS/architecture boundary: the ISA and hardware provide cores and registers; the kernel scheduler decides who uses them.

Learning outcomes

Core concepts

Communication chain: system calls → processes → threads

Applications use libraries and binaries to make system calls to the kernel; the kernel services them from available resources. System calls create processes, each with a PID. Processes communicate with each other. On workload creation, threads are created and resources allocated to threads. Why it matters: this chain is the entry point for everything else in the class — scheduling acts on the threads/processes this chain produces.

Opening scenario: flash-sale latency

An e-commerce platform during a flash sale: high traffic, high CPU utilization, unequal response times. Chat brainstorm causes were consolidated into: too many simultaneous requests; insufficient CPU capacity; database/network delays under high traffic; excessive threads; long-running computation; tasks waiting in queue; inefficient scheduling or synchronization. Key point: CPU scheduling delay must be distinguished from other latency sources — a thread may be waiting on a database, waiting in an application queue, or ready-to-run but not yet given CPU time. Request flow: incoming request → application queues → worker threads → runnable threads → compete for CPU → execute → response.

CPU scheduling

Given ready tasks and fewer cores than tasks (e.g., four tasks, one core), "somebody must decide which task runs first, how long it runs, and when another task gets set up. That decision-making process is called CPU scheduling." Scheduling is making threads wait in a queue but processing them as soon as possible — the CPU is not left idle, not even a millisecond, while there are tasks and instructions to execute. Objectives ("CTWR"): completion time, turnaround time, waiting time, response time — all time-based. Which to optimize depends on workload and service objectives; there is no straight yes/no answer.

Scheduling criteria

No single criterion or metric fully describes scheduling quality. Criteria: CPU utilization; throughput (jobs completed per unit time); turnaround time (completion time); waiting time; response time; fairness (equitable service allocation).

Processes and threads

Thread control

Unless you are building an OS environment for your own application, thread control is not done at the system level; it is controlled in the application call itself. The application call generates processes, and processes generate threads — control happens through system calls, not at the thread or process level.

The "one core" model

The lecturer insists: a processor is not "single core", it is one core. One core is a resource that can be split among processes and threads, so multiple processes can execute on a one-core CPU at a given point of time. Assigning a process to a core does not assign the entire core — it allocates only what is required; the rest can be picked up by another process, and both coexist. Whether you run one task or many on one core depends on application design (e.g., Java applications get this managed by the OS layer). Rather than leaving CPU idle, we try to utilize all of it with multiple processes and tasks; it just won't be "super fast" like a core performing alone.

Race conditions on one core: with a single core and more than one task trying to execute, you will not get into that risk situation, because scheduling activity happens once the thread is created. Example: 13 threads waiting; four can execute at a given point of time, so the first four are scheduled, then the next four, then the next two. If all 10 fit, all 10 fit and you get a response; either way it works and gives the throughput. The only question is the extra millisecond of delay — hence the opening scenario's "response not received": have a little patience, especially under expected heavy traffic.

Concurrency vs. parallelism

Context switch

Event (application request; timer, block, yield, or wake-up) → save the state needed to resume the current task → scheduler chooses eligible work → restore the next execution context → next task continues. The switching itself is overhead, though the system benefits from sharing CPU time. Once assigned to a core, a task is not guaranteed to run to completion — the scheduler may let it finish or interrupt it, put it back into its waiting state, and later allocate the CPU again so it continues from that state. This is common in long or high-utilization workloads, especially data engineering and data science. The scheduler may interrupt based on latency, throughput, and CPU utilization: if 10 workloads are processing at 85% utilization, at 95–96% some may be interrupted and pushed back to wait to keep the system healthy.

Context switch level (Q&A): context switching happens at the thread level, but the reference is always at the process level — "thread only gets the resources," but "process only creates threads," so everything is referred to the process. Swap-in/swap-out at process level and context switching at thread level should not be treated as two different mechanisms. Under many requests, the same process appears to have multiple process IDs because those are threads; the parent process (PPID) closes only after all children. Parent–child relationships can be created by processes and also influenced by threads. "Thread is born from the process."

CPU vs. GPU workloads

On workload creation, a system call creates the process and its threads; resources are allocated to the thread. If the workload requires the GPU, it goes to the GPU, not the CPU; the CPU is only for non-GPU requirements. There is no overlap and hence no clash between the same process running on CPU and GPU. If the GPU is full and the workload is GPU-based, it waits for the timeout before even selecting the CPU to get it processed; certain commands (an overlap) will work. Context switching is related to the workload assigned to the interface.

Concurrency/parallelism with CPU + GPU in one program: if a program does some work on CPU and heavy data lifting/serialization on GPU within the same process/thread, the threads execute at the same time, but this cannot be called concurrency or parallelism, because those come only if the same resource is used by the process. GPU is a different resource from CPU, so no credit for parallelism or concurrency. If the division happens at the thread level, it is not parallel either.

Scheduling algorithms

FCFS (First Come First Served). Executes in queue order irrespective of any priority. Strength: simple, predictable ordering, no complexity in queue maintenance. Disadvantage: short jobs may wait behind long jobs — a long task can delay several short tasks behind it; commonly called the convoy effect. FIFO-like behavior is expected in simple job queues or ordered processing and where fairness by arrival order matters (example: whoever pays first should have their payment confirmed before the next payment is accepted/processed). Caveat: a FIFO application queue is not necessarily the same as the OS scheduling policy — the CPU policy is totally different from a FIFO policy in the application queue.

SJF (Shortest Job First). Selects the ready process with the shortest CPU burst. Strength: minimizes average waiting time (short jobs don't wait) and brings down average turnaround time. Caveat: holds for the given workload where all processes arrive together and burst lengths are known, but production systems do not generally know the exact future CPU burst for every task. SJF as described is non-preemptive.

SRTF (Shortest Remaining Time First). Preemptive SJF: a newly ready process can replace the running process if it has a shorter remaining CPU burst. Example: if P1 is processing and P5 arrives with a burst of 3 seconds, there is a context switch — P5 executes first, then P1 continues from where it left off.

Priority scheduling. Selects the highest-priority ready process; lower numerical value = higher priority. Strength: favors urgent/critical work (example: a payment can be given priority zero, the topmost priority, so it is handled even in a critical state). Weakness: low-priority work may be postponed indefinitely. The example discussed is non-preemptive; priority scheduling can also be preemptive.

Round robin (time sharing). Preemptive scheduling lets the OS take the CPU away before the task completes its current CPU burst; a common trigger is expiration of a timer-based time slice. A quantum is defined (2 milliseconds in the example). Each process gets up to the quantum; if it finishes, it leaves the system; if it has remaining work, it goes to the back of the ready queue. Greatest advantage: we can restrict the queue from going up. Quantum is a design parameter: too small → the scheduler spends a larger proportion of time switching (switching carries a cost — the time to switch two different processes); too large → round robin approaches FCFS behavior.

Preemption, starvation, aging. Preemption alone does not guarantee fairness. Starvation occurs when a task waits indefinitely or unacceptably long because other tasks continuously receive preference — e.g., a low-priority batch report repeatedly postponed by newly arriving high-priority tasks. Example: in a payment flow, payments get highest priority, adding to cart next (since the item is shortlisted and the next stage is payment), then identifying/keeping — compared to copper, silver, and gold tiers. Starvation comes into the picture when a process waits a long time to receive the signal, possibly continuously switched out because higher-priority work keeps arriving; when it waits, aging also comes into the picture.

Aging, starvation, deadlock, preemption, fair scheduling

Where priorities/weights come from

They are not decided by the scheduler from a predefined dictionary in the libraries; they are assigned when the system call is made. Application threads send the priority along with the request to the system call, and that is how it is conveyed to processes and threads.

Fairness policy is "stitched on the go" — at the time the workload is defined, not at the time data is received. Example: a stock-exchange source is defined with weightage 2, a customer connection with weightage 1; the appropriate ratio is then provided as data arrives. Definition first, then processing.

Default weightage — a process with no weightage defined gets the default weightage of zero; weighted processes get their fair share, and the available (leftover) share is given to the unweighted data.

Kernel scheduler — the component that manages weight distribution / weight analysis behind the screen (transcript renders it as "KPU scheduler"; intended term is kernel scheduler).

The copy is a program — in the device-to-device transfer scenario, the copy operation itself is a program running behind the scenes; the scheduler must make a real-time policy for it.

Threshold — a defined limit on how much CPU a stream may use; the lecturer assumes a threshold of 60%.

Application threads vs. processes — if you control threads via the application you are writing, they are application threads; application threads get into independent processes and are processed. If the process is not going to create any threads, your application threads become processes. (The lecturer said he was not sure what "thread per core" meant and asked for clarification; lscpu was mentioned but the point was not developed.)

Algorithm comparison (same workload, same burst data)

Lecturer's framing: for better turnaround, prefer SJF; for better response, Round Robin. But Round Robin has the disadvantage of the longest completion/turnaround time because it goes with the quantum. Weigh advantage and disadvantage, constraint and benefit, before deciding.

| Algorithm | Average waiting | Average turnaround | Average response |

|---|---|---|---|

| FCFS | — | — | — |

| Non-preemptive SJF | 3.75 ms (lowest) | 7.75 ms (lowest) | — |

| Non-preemptive Priority | — | — | — |

| Round Robin (quantum = 2) | — | — | 2.75 (lowest) |

(Cells marked — were not stated numerically in this part.)

Linux scheduling — ordinary Linux scheduling is not simply a choice among the four textbook policies. The practical exercise uses Linux to observe real threads and to simulate the textbook algorithms explicitly, comparing observed behavior with the simplified models.

Formulas and maths

Notation: A = arrival time, B = CPU burst, C = completion time, S = first CPU start, T = turnaround time, W = waiting time.

Transcript

One line per segment, [hh:mm:ss] timestamp first.

loading…