User programs are written under the illusion that they have the entire machine, which means that the operating system must manage/protect machine resources correctly to maintain this illusion for multiple processes. In Pintos, more than one process can run at a time, and as in other POSIX-like systems, each process can have multiple threads. Remember that it is individual threads, not the processes which own them, which actually execute on the CPU.
Pintos can run normal C programs, as long as they fit into memory and use only the system calls you implement. Notably,
malloc cannot be implemented because none of the system calls required for memory allocation (e.g.
sbrk for memory allocation) are required for this project. Note that until you complete Project User Programs in its entirety, many programs will fail due to depending on unimplemented components. For example, until you implement Floating Point Operations, programs that use floating point operations will intermittently fail, as you won’t have implemented the functionality necessary for the kernel to save and restore the floating-point registers between context switches.
src/examples directory contains a few sample user programs. The
Makefile in this directory compiles the provided examples, and you can edit it to compile your own programs as well. Pintos can load ELF executables with the loader provided for you in
userprog/process.c — it can be informative to try and see which Linux userland utils are able to run after you’ve implemented Project User Programs.
Until you copy a test program to the simulated file system, Pintos will be unable to do useful work. You should create a clean reference file system disk and copy that over whenever you trash your filesys.dsk beyond a useful state, which may happen occasionally while debugging.
Table of contents
- Source files
- How user programs work
- Virtual memory layout
- Accessing user memory
- Switching threads
- 80x86 calling convention
- Program startup details
- Adding new tests to Pintos