abstraction.md (2095B)
1 # Abstraction 2 3 The use of abstractions is one of the most important concepts in computer 4 science. For example, one aspect of good programming practice is to formulate a 5 simple application program interface (API) for a set of functions that allow 6 programmers to use the code without having to delve into its inner workings. 7 Different programming languages provide different forms and levels of support 8 for abstraction, such as Rust's trait definitions and module system with 9 explicit pub visibility boundaries. 10 11 ## Abstractions provided by a computer system 12 13 <img src="/whiteboards/abstraction_of_computer_system.png" alt="Abstraction" width="100%"> 14 15 We are probably familiar with several of the abstractions seen in computer 16 systems. On the processor side, the instruction set architecture provides an 17 abstraction of the actual processor hardware. With this abstraction, a 18 machine-code program behaves as if it were executed on a processor that performs 19 just one instruction at a time. The underlying hardware is far more elaborate, 20 executing multiple instructions in parallel, but always in a way that is 21 consistent with the simple, sequential model. By keeping the same execution 22 model, different processor implementations can execute the same machine code 23 while offering a range of cost and performance. 24 25 On the operating system side, we have introduced three abstractions: files as an 26 abstraction of I/O devices, virtual memory as an abstraction of program memory, 27 and processes as an abstraction of a running program. To these abstractions we 28 add a new one: the virtual machine, providing an abstraction of the entire 29 computer, including the operating system, the processor, and the programs. The 30 idea of a virtual machine was introduced by IBM in the 1960s, but it has become 31 more prominent recently as a way to manage computers that must be able to run 32 programs designed for multiple operating systems (such as Microsoft Windows, Mac 33 OS X, and Linux) or different versions of the same operating system. 34 35 <img src="/whiteboards/five_abstraction_levels.png" alt="Abstraction" width="100%">