Agenda
<aside> 📌 Reminders
In P1 we exclusively handled kernel code (code that ran as part of the OS), even test cases were running as part of the kernel. This is not very useful in practice, imagine if the OS on your computer couldn’t run any other programs, you’d be stuck with a machine that runs the OS and nothing else. We want to be able to support third part applications and code, we’ll refer to these as user programs in the context of pintOS
<aside> 💡
User program: a piece of code that runs outside of the kernel
</aside>
Allowing programs written by other user to run on the machine can also pose serious risks if when don’t be careful (we saw an example in week 2).
System calls allow us to give user programs controlled access to hardware and OS services.
<aside> 💡
System Call: a procedure that the OS exposes to user programs to give it access to hardware or an OS service (e.g. filesystem, console, etc.)
</aside>
Rather just giving a user program hardware access, the OS acts as a middle-man that mediates between the user program and the hardware, ensuring that only valid and safe operations are performed. This helps prevent user programs from accidentally or maliciously corrupting the system.
There are numerous types of system calls, many of which you will be familiar with from your own use of them
File System Operations
These allow programs to interact with files, such as reading, writing, or deleting files. System calls like open(), read(), and write() fall under this category.
Process Management
These include operations related to managing processes, such as creating, terminating, or scheduling processes. Common system calls include fork(), exit(), and wait().
Inter-process communication
Not as relevant for our purposes
and more…