A running program does one very simple thing: executes instructions.
So within every second, the processor simply just fetch an instruction from memory, decodes it, and executes it.
And it’s the OS’s job to make it easy to run programms, allow program to share memory, enable program to interact with devide and all other stuff.
How does the OS do it then? The primary way is through a technique called virtualization. The OStakes a physical resource (such as the processor, or memory, or a disk) and transforms it into a more general, powerful, and easy-to-use virtual form of itself. Thus, we sometimes refer to the operating system as a virtual machine. A typical OS exports few hundred system calls that are avaliable to applications, and we can say that the OS provides a standarad library to applications.
The OS is also a resource manager. Each of the CPU, memory, and disk is a resource of the system; it is thus the operating system’s role to manage those resources, doing so efficiently or fairly or indeed with many other possible goals in mind.
The goal of OS is:
Given that we want to build such a system, we want to have some goals in mind to help focus our design and implementation and make trade-offs as necessary; finding the right set of trade-offs is a key to building systems.