This week we got started with the course and covered a lot of ground: computer architecture, C programming, the history of Unix and Linux, and the core abstractions that operating systems provide. The reading from OSTEP Chapter 2 paired well with the lectures, and it looks like it should be a helpful resource for the rest of the course.
Topics covered this week
Some of the topics we covered were:
- Computer architecture
- Basic components of a computer (Von Neumann model)
- The CPU fetches instructions from memory and then executes them.
- The system’s memory (RAM or volatile storage) stores instructions and the data that the instructions will operate on, while non-volatile storage, like a hard drive, stores persistent data.
- I/O devices act as an interface between the system and users, or other systems over the network.
- Buses connect the different components of the system. Faster buses are closer to the CPU.
- The storage hierarchy refers to different types of storage used by a computer. The fastest storage, like CPU registers, store the least amount of data, while slower storage, like a hard drive, can store more data, but is slower.
- The operating system as a resource manager
- The OS allocates CPU time, memory, and disk space fairly and efficiently across all running processes.
- Physical vs. virtual memory
- Physical memory is the actual RAM in the computer, while virtual memory is an operating system abstraction that gives each program its own address space and maps those addresses to physical memory.
- The memory layout of a running program describes how the system stores different kinds of data needed to run a program. For example, The program code and heap are stored at the beginning of the memory block, while the call stack are stored at the end.
- Basic components of a computer (Von Neumann model)
- Function calls and the stack
- The system stores function calls in a LIFO memory structure called the call stack. In an x86 architecture, the esp register points to the top of the stack, and the ebp register points to the stack frame, which contains data related to the function call, e.g., arguments, local variables, and the return address.
- The C programming language is a simple, low-level language created by Dennis Ritchie at Bell Labs in 1973. Many operating systems, like Linux, are implemented in C, and many programming languages, like JavaScript and Go, use the familiar C syntax.
- Data types
- C has supports primitive data types, like char, int, long, float, and double, which are the basis for derived types like pointers, arrays, and structs.
- Pointers point to locations in memory, which is useful for passing a reference to data that a function should modify.
- Structs are structured data types, similar to objects, but without object-oriented behavior, like inheritance. Structs can be used for creating a custom data type, like a String.
- Memory allocation in C is handled manually by functions like malloc, calloc, and free.
- Data types
- Linux and the shell
- Unix and Linux history
- Unix was created by Ken Thompson and Dennis Ritchie at Bell Labs in 1969.
- Linux was created by Linus Torvalds in 1991 as a clone of Unix. Many programs from the GNU software project were integrated with the Linux kernel to create the Linux operating system.
- Shell scripting with bash
- The shell describes the command-line interface between the user and the OS.
- The shell reads commands entered by the user, interprets them, and then asks the operating system (usually through system calls) to execute the requested actions.
- The Bourne Again Shell (bash) is a commonly used shell.
- Unix and Linux history
Reflection
After reviewing these topics, the area that I’m least familiar with is low-level memory management. I tend to use higher-level programming languages, like Python and JavaScript, where memory management isn’t handled by the programmer. We explored memory management a bit in this week’s programming assignment, so I’m getting some more experience with it.
Structs and pointers are a bit easier for me to understand, since these concepts are often used in higher-level programming languages. I’m familiar with the difference between passing by value vs. passing by reference and object-oriented programming, so I’ve been able to translate that knowledge to C programming.
I’m also pretty familiar with Linux, and recently earned my Linux+ certification. It looks like next week’s lesson will cover process management. I’m already familiar with Linux concepts like systemd, process kill signals, and controlling background tasks, so it will be interesting to see how that is handled at the hardware level.