Week 4.a CS6640 01/27 2026 https://naizhengtan.github.io/26spring/ □ 0. recap: gdb w/ an example □ 1. OS organization □ 2. egos desgin ---- 0. gdb * gdb basics Scenario 1: "what's wrong?" - run to failure - use gdb to see the final status Scenario 2: "I suspect this is wrong" - set a breakpoint - continue the egos - run until the breakpoint - single step running & monitoring * use cases for gdb a) Question: At what memory address does the CPU execute the first kernel instruction? -- use gdb b) Question: How does printf() work? use gdb: -- go with code in Lab1 [see printing a letter at a time] c) Question: How does context switching work in Lab 2? * a tricky bug in the lab2 example: wrong stack pointer [example: stack problem] 1. OS organization: part I: OS architecture part II: egos design and implementation Expectation: after this, you should have a bird view of egos Why we have this now, instead of the first class? - an analogy of OS organization vs. Software architect - for software engineering, one studies how to program, then algorithms and data structures, then design patterns and software engineering (as in management), then software architecture => low-code programmers, programmers, software engineers, software architect - where OS education is the other way around: OS users, [?] OS architect A) Part I - types of OSes [see fig] * monolithic OS * microkernel OS: 1970s * exokernel (LibOS): 1995 * multikernel: 2009 - more about these architectures * monolithic kernel: a single piece of code serving all requests high in coupling * microkernel: kerenl is mostly responsible for IPCs; services are running in user-level low in coupling IPC can be the bottleneck * Improving IPC by kernel design, SOSP 1993 * exokernel kernel only handles multiplexing resources (securely) extra performance due to having hardware primitives * Exokernel: An Operating System Architecture for Application-Level Resource Management, SOSP 1995 * multikernel target heterogeneous hardware and many-core machines replace shared-memory model with shared-nothing model (use message passing) treat OS as a distributed system * message passing vs. shared memory * The multikernel: a new OS architecture for scalable multicore systems, SOSP 2009 - [story] an anecdote of today's microkernel * Microkernel Goes General: Performance and Compatibility in the HongMeng Production Microkernel, OSDI 2024 2. egos design * earth, grass, and apps [see handout, panel 1] * earth interface and syscalls [read library/egos.h] * two syscalls: sys_send, sys_recv (library/libc/syscall.h) * system services -- sys_proc (GPID_PROC) -- sys_terminal (GPID_TERMINAL) -- sys_file (GPID_FILE) -- sys_shell (GPID_SHELL) They have well-known pids, from 1 to 4. * pid to proc_set's idx -- 1-to-1 mapping -- see [grass/process.c]