> For the complete documentation index, see [llms.txt](https://xiayingp.gitbook.io/build_a_os/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiayingp.gitbook.io/build_a_os/os-interfaces/os-interfaces.md).

# OS interfaces

#### The job of OS is

1. Share programs.
2. Abstract low-level hardware, so program need not concern what disk is being used.
3. Provide ways for programs to interact.

#### Design philosophy

OS defines interfaces to be simple and narrow. Combine programs to provide much generality.

#### User space and Kernel Space

![](/files/-M4bienH9ewqFuJ1nrOo)

When a process needs to invoke a kernel service, it invokes a system call. The system call enters the kernel, the kernel performs the service and returns.

#### Privileges

Kernel uses CPU’s hardware protection mechanisms to ensure each process in user space can only access its own memory. When a user program invokes a system call, the hardware raises the privilege level and starts executing a pre-arranged function in kernel.

#### The shell

The shell is an ordinary program that reads commands from the user and executes them. In our journey, we will be implement a new shell ourself (see lab2).

#### Xv6 system calls

![](/files/-M4biiC7VryvQEdiTwMM)
