Mental model
This page discusses strategies to deepen of the complex OS architectures.
Reading the man pages to know and understand more details of C
If you don't know a C function, you can search in the man manual. The man pages seem a bit complicated at first, but the more you read them and dig into the C and OS universe, the more you'll understand what is happening. They have a certain level of technical jargon, but the SYE course will also help you better understand where this is coming from.
while ((next_token = strtok(NULL, " ")) != NULL)
strcpy(tokens[i++], next_token);
Let's say you see this snippet and you are lost... What is strtok, strcpy, ... ? Open man strtok and man strcpy and start reading.
Read interesting files from SO3
I get what is a process, just a stuff running when I start a program. I see the slides with a lot of different info about processes, in the PCB, but how is it actually coded ?
A shell ? Yeah the thing that runs my command when I type them. But does it work actually ?
When does the process state is changed ?
SO3 has the very big advantage of being a small OS (around 350'000 lines of C code). As you understand the basics of C with PRG2, you can totally read some source code to better understand how it works in practice. Some parts are very simplified and this is making it pretty easy to read, decode and understand the idea.
You may want to read a few files right after the course on the related subjects. Here are a the parts I recommend to read. Some of them have a lot of comments to understand why these lines are needed.
-
To see how a very basic program you use everyday is developed, read
usr/src/cat.candusr/src/ls.candusr/src/echo.c -
To help you figure out What is really a shell ? What happens when I run Bash or Fish ? Read
usr/src/sh.c: that's a very basic shell and you can understand every part with a bit of research.- Understand the steps of preparing the arguments from
echo hey there->["echo", "hey", "there"]-> forking -> loading the binary code in memory withexecve - Make sure to understand the difference between external binaries in
.elfand shell builtins such asexit - What is doing
kill? - List all the shell builtins and their goal
- How is the signal sent by Ctrl+c is managed ?
- Understand the steps of preparing the arguments from
-
To better understand the management of processes read
so3/include/process.h:- make sure to understand every field of
struct pcb(reminder: Process Control Block -> the struct that describes each process), and then you'll get a deeper view on what is really a process ? how it is described ? - see
do_forkanddo_execve(ctrl+click to find the definition) to understand the basics of What happens when I runfork()andexecve()from my userspace program ? - take a look at
do_getpid(ctrl+click to find the definition) and dig into it to find where is the global variable storing the current thread - you can continue with other functions if your curiosity is asking it like me
- make sure to understand every field of
-
To better understand the management of threads read
so3/include/thread.h- make sure to understand
enum thread_state_tandstruct tcb - read the syscalls implementation of
do_thread_create,do_thread_joinanddo_thread_exit - make sure to read
thread_createas well, you'll see how atcbis initialized
- make sure to understand
-
If you want to see a possible way to implement a scheduler (in French l'ordonnanceur) see the functions in
so3/kernel/schedule.c- read
ready(),waiting(),zombie() - read
next_thread() - if you are courageous, read the core scheduler function
schedule()
- read
If you took the time to dig into it a few hours, I'm sure you'll be happy of the investment.
There are probably a lot more things that are accessible and interesting, it's up to you to discover them :)