San Jose State University : Site Name


Main Content

Kernel Memory

Ronald Mak

Department of Computer Engineering
Department of Computer Science
Department of Applied Data Science
Spring Semester 2021

Office hours: TuTh: 4:30-5:30 PM
Office location: ENG 250

CMPE 142 Operating Systems

Section 1: F 12:00 noon - 2:45 PM online via Zoom


# Assigned Due Assignment
1 Jan 29 Feb 5 Ubuntu and the bash Shell
2 Feb 5 Feb 12 Pipes

Input file: presidents.csv
Expected output file: presidents.html
Example solutions: ReadCSV.c   MakeTable.c (C) (C++)
3 Feb 12 Feb 26 Process scheduling algorithms

Example solution:
4 Feb 26 Mar 5 Interprocess communication

Example solutions:
5 Mar 5 Mar 12 Memory allocation algorithms

Example ncurses program: DotsAndStars.c
Example solutions:
6 Mar 12 Mar 26 Page replacement algorithms

Example solution:
7 Apr 9 Apr 16 Disk scheduling algorithms

Example solution:
8 Apr 16 Apr 23 POSIX file system functions

Example solution:
9 Apr 23 Apr 30 POSIX select() and socket connections

Example solution:
10 Apr 30 May 7 Install a VMM and a Linux distro


Week Date Content
1 Aug 20 Zoom recording Passcode: n&!5qyr5
Slides: Course objectives; project teams; postmortem report; grading; what is an operating system; virtual views; hardware generations; batch systems: IBM 1401 and 7094; historic operating systems; evolution of UNIX; interfaces; POSIX; macOS; Windows; Linux; bash shell; Assignment #1
2 Feb 5 Zoom recording Passcode: AU5.?m3z
Slides: Abstractions: processes, memory, file systems; fork(); compile and run C and C++ programs; mounted file systems; stdin and stdou; shell; I/O redirection; pipes; POSIX functions; kernel mode vs. user mode; system call workflow; OS structures: monolithic, layered, microkernel, client-server, virtual machines; hypervisors

Example programs: echo.c   echo.pp   forktest.c   tagger.c   tagger.cpp
3 Feb 12 Zoom recording Passcode: +T2u@e^A
Slides: Processes; memory layout; process models; process control block; context switching; process creation and termination; process states; process scheduling; process behavior; scheduling algorithms; dispatcher; first-come-first-served; shortest job first; shortest remaining time; round robin; context switching; highest priority first; shortest process next; lottery and fair-share scheduling; interrupt handler routines; threads; thread scheduling; POSIX threads
4 Feb 19 Zoom recording Passcode: 9rY=fpGV
Slides: Interprocess communication: shared memory, message passing, direct and indirect communication, named pipes; client-server communication: sockets, remote procedure calls; message synchronization; process synchronization; race condition; mutual exclusion; critical region; lock variables; busy waiting; Peterson's solution; test and set lock instruction; priority inversion; sleep and wakeup; semaphores; mutexes; synchronized producers and consumers; problems with semaphores

Example programs:
5 Feb 26 Zoom recording Passcode: =0*yfr!*
Slides: Threads; Office Hour multithreading example; readers-writers problem; dining philosophers problem; C++ threads, mutexes, and condition variables; C++ Office Hour; deadlock conditions; resource contention; deadlock modeling; deadlock example

Example programs:   OfficeHour.cpp   PrintMutex.cpp   QueueSync.cpp   deadlock.c
6 Mar 5 Zoom recording Passcode: Ae$Qut&5
Slides: Deadlocks: strategies, detection, recovery, prevention; global resource numbering; deadlock avoidance; resource trajectories; banker's algorithm for a single resource and for multiple resources; two-phase locking; memory management; computer system architecture; memory hierarchy; memory/storage speed comparisons; memory manager; monoprogramming systems; fixed partitions; process relocation; process protection; address binding Logical vs. physical address space; dynamic loading and linking; swapping; variable partition scheme; memory compaction; memory demands; keeping track of memory; memory allocation algorithms; memory fragmentation

Example ncurses program: DotsAndStars.c
7 Mar 12 Zoom recording Passcode: gC.Y0^jT
Slides: Internal vs. external fragmentation; paging; shared pages; multilevel page tables; page table entry; translation lookaside buffer (TLB); TLB hit ratio; inverted page tables; segmentation; paging vs. sementation; virtual memory; demand paging; page fault; copy-on-write; page replacement; first-in first-out (FIFO); second chance; least recently used (LRU); least frequently used (LFU); most frequently used (MFU); random pick; working set; thrashing; page fault frequency (PFF);
8 Mar 19 Zoom recording Passcode: C1US02#f
Slides: Locality model; working set model; local vs. global page allocation; working set and page fault rate; prepaging; page size; TLB reach; program structure; kernel memory; buddy system; memory-mapped files; Intel memory management; ARM memory management; Linux memory management; review for the midterm

Example memory-mapped file program:
9 Mar 26 Midterm

Zoom recording Passcode: P*%E7M7n
Slides: OS design goals and challenges; hide the low-level hardware; interface design principles; layered OS architecture; performance; space-time tradeoff; The Mythical Man Month; OS trends

Recommended book: The Mythical Man-Month
10 Apr 9 Zoom recording Passcode: F&DcKK4!
Slides: Midterm solutions; hard disk drive; solid state disk; secondary storage connection methods; disk scheduling: FCFS, SSTF, SCAN, C-SCAN, LOOK, C-LOOK; scheduling choices; Assignment #7; storage device management; error detection and management; hierarchical storage management; RAID; file systems; files; file types; file attributes; file operations; opening a file; internal file tables; file locking; file structure; sequential access method; direct (random) access method; disk structure; directories; directory operations; single-level directory; two-level directory; tree-structured directory; acyclic-graph directory; file path names; mounting a file system; file protection
11 Apr 16 Zoom recording Passcode: wP0dA=1A
Slides: Mounting a file system; file protection; layered file system; disk layout; file allocation: contiguous, linked, FAT, indexed; UNIX inode; implementing directories; UNIX directories; UNIX file file system exercises; fswatch; Assignment #8; disk block size; free disk space management; file system reliability; bad blocks; backups and dumps; file system consistency; file system performance; journaling file systems; virtual file system (VFS); network file system (NFS); NFS mounting; types of I/O devices; hardware to support I/O; bus architecture
12 Apr 23 Zoom recording Passcode: p5dJZE@@
Slides: Virtual file system (VFS); network file system (NFS); NFS mounting; types of I/O devices; hardware to support I/O; bus architecture; device controllers; memory-mapped I/O; direct memory access (DMA); I/O software layers; device drivers; device-independent software; I/O interrupts; synchronous and asynchronous I/O operations; kernel I/O subsystem; polling; I/O interrupts; software interrupts; traps; application-level interrupt handlers; clocks and timers; sockets; select(); how fast?; multiprocessor systems; multiprocessor OS; remote procedure call (RPC); distributed shared memory (DSM)

Example programs: signal.c   timer.c   TestSelect.c
13 Apr 30 Zoom recording Passcode: &M9K66jf
Slides: Virtual machines; virtual machine managers; host vs. guest operating systems; virtualization requirements; history; benefits; implementation; type 2 hypervisor; virtualization components; Assignment #10; distributed systems; advantages; network operating systems; distributed operating systems; network structure; local area network (LAN); wide area network (WAN); communication structure; naming and name resolution; domain name service (DNS); routing strategies: fixed, virtual, dynamic; connection strategies: circuit switching, message switching, packet switching; contention; CSMA/CD; communications protocols; ISO network model; TCP/IP protocol layers; Ethernet packet transmission; failure detection; reconfiguration; network design issues
14 May 7 Zoom recording Passcode: b$4MAfQ3
Slides: Distributed file system (DFS); DFS structure; naming and transparency; naming schemes; remote file access; cache update policy; caching consistency; protection; Principle of Least Authority (POLA); protection granularity; protection domains; UNIX domains; UNIX domain switching; access matrix; role-based access control; program-level protection; security; security violations; violation methods; the bad guys; layers of security; man-in-the-middle attack; trojan horse attack; trap door attack; logic bomb; stack and buffer overflow; virus categories; ransomware; keystroke logger; port scanning; denial of service; design principles for security; user authentication; security firewalls; nontechnical lecture on public key cryptography; cybersecurity career
15 May 14 Zoom recording Passcode: 8&a3Fg9Y
Slides: Case studies: Linux, Windows 10, Android; review for the final.


This class will use UNIX, Linux, and the POSIX standard as examples throughout the semester. Students will get practical hands-on interactive and programming experience to acquire real-world skills desired by employers.

Course Learning Outcomes (CLO)

Department policy is to enforce
all course prerequisites strictly


CMPE 102, CMPE 126 (all with grades of "C-" or better).
Computer Engineering or Software Engineering Majors Only.

Recommended books

Modern Operating Systems, 4th edition
Andrew S. Tanenbaum and Herbert Bos
Pearson, 2014
Operating System Concepts, 10th edition
Abraham Silberschatz, Greg Gagne, and Peter B. Galvin
Wiley 2018
Linux Command Line and Shell Scripting Bible, 4th edition
Richard Blum and Christine Bresnahan
Wiley 2021
Bash Scripting Tutorial for Beginners

Useful tutorials

Some useful tutorials for my classes where the preferred platforms for application development are MacOS X and the Ubuntu distribution of Linux. Windows 10 may present significant compatibility challenges.