1.1 Information is bit + context
Bit understanding: The source program, such as HELLO.C, is actually a bit composed of values 0 and 1, 8 bits that make up a group, and become bytes, such as 00011000. Each byte represents some text characters in the program, and each byte has an integer value. As ' \ n ', it has an integer value of 10, or 00001010. If a file is made up of ASCII characters, it is called a text file, and all other files are called binary files.
All information in the system-including disk files, in-memory programs, user data stored in memory, and network uploads-is represented by a string of bits. The context, which can be understood as an identical sequence of bytes, may represent an integer, a floating-point number, a string, or a machine instruction.
1.2 programs are translated into different formats by other programs
The life cycle of the Hello program begins with a high-level C language Program, in order to run the program, each C statement must be converted by another program into a series of low-level machine language instructions, and then these instructions are in accordance with a format called executable target program, and stored in the form of binary disk files.
Preprocessing phase: The preprocessor modifies the original C program based on a command that begins with the # character #. such as the #include<stdio.h> command tells the preprocessor to read the contents of the system header file stdio.h and insert it directly into the program text, so that the hello.i file is obtained.
Compile phase: The compiler translates the hello.i file into a Hello.s file, which contains an assembly language program, each of which describes a low-level machine language instruction in a text format.
Assembler stage: The assembler translates hello.s into machine instructions, packages these instructions into a format called relocatable Target program, and saves the results in HELLO.O.
Link stage: The Prinf function is called in the Hello Program, and the Prinf function exists in a separate precompiled target file named PRINF.O, which must be incorporated in some way into our hello.o program. The linker is responsible for processing the merge, and the result is a hello file, which is an executable target file.
1.3 Understanding how the compilation system works is beneficial
- Optimizing Program Performance
- Understanding the error that occurs when linking
- Avoid security breaches
1.4 Processor reads and interprets instructions stored in memory
This means that the Shell,hello program that we used to run the command is compiled into the executable target file, the shell loads and runs its message with the output Hello program, and then waits for the next command line.
Hardware composition of 1.4.1 system
Bus: Throughout the system;
I/O devices: input (keyboard, mouse, etc.), output (display, etc.)
Main memory: A temporary storage device used to store data processed by programs and programs when the processor executes the program. Physically, main memory consists of a set of dynamic random access memory dram chips.
Processor: The engine that interprets or executes instructions stored in main memory, the core of which is the program counter PC, which points to a machine language instruction in memory each time. The processor points to the memory-out read instruction from the program counter, interprets the bits in the instruction, executes the simple action indicated by the instruction, and then updates the PC to point to the next instruction, which is not necessarily adjacent to the instruction just executed in memory.
Actions that the CPU may perform:
Loading: Copying a byte or a word to a register from main memory;
Storage: Copying a byte or a word from a register to a location in main memory;
Action: Copy the contents of the two registers to Alu,alu to do arithmetic operations on the two words and store the result in a register to overwrite the original contents of the register.
Jump: Extract a word from the instruction itself and copy the word to the PC to overwrite the original value of the PC.
1.4.2 Hello program Run
Initially, the Hello program is placed on disk;
When the program loads, copy from disk to main memory
When the processor is running, the bytes are copied from main memory to the register file and then copied from the register file to the display device, which is eventually displayed on the screen.
This, at the beginning of the disk, and then copied to main memory, and finally copied from the main memory to the display device, copy to copy is not the extra cost, is it possible to improve speed? (cache)
1.5 Cache is critical
Locality principle: The cache contains data that can be accessed frequently, and most of the memory operations are done in a fast cache.
Conclusion: Cache memory applications programmers can use caching to improve program performance by an order of magnitude
1.6 Storage Device Formation hierarchy
The idea of inserting a smaller and faster storage device (cache) between the processor and a larger, slower device (main memory) has become a universal concept
1.7 Operating System Management hardware
Running Hello programs do not have direct access to the keyboard Ah mouse monitor These they rely on the operating system to provide services
Operating system has two basic functions one is to prevent hardware runaway application misuse the second is to provide the application with a simple and consistent mechanism to control complex and often very different low-level hardware devices
, the file is an abstraction of the IO device, which is an abstract representation of main memory and disk I/O devices, and the process is an abstract representation of the processor, main memory and I/O devices;
1.7.1 process
A process is an abstraction of the operating system for a running program
Context: The operating system keeps track of all the state information required for the process to run, such as PC, register current value, main memory content, etc.;
Context Switch: Saves the context of the current process and restores the context of the new process;
Transitions from one process to another are managed by the operating system kernel. For example, reading a file, the application executes a special system call instruction, passes control to the kernel, and then the kernel executes the requested operation and returns the application.
1.7.2 Threads
Threads: A process can consist of multiple execution units called threads, each running in the context of a process and sharing the same code and global data. Multithreading is easier to share data between multiple processes than a process, and threads are generally more efficient than processes.
1.7.3 virtual memory
Virtual Memory: Virtual memory is an abstraction that provides an illusion for each process that each process uses the main memory exclusively. Each process sees the same amount of memory, called the virtual address space.
program code and data: code data defined by the user process;
Heap: Run-time heap;
Shared library: C standard library;
Stack: function call;
Kernel virtual memory: reserved for the kernel, does not allow the application to read and write this area content;
1.8 using network communication between systems
The network provides a means of communication between computer systems. From a special system point of view, the network is an I/O device.
The Telnet client on the local host connects to the Telnet server on the remote host, as follows:
1.9 Important topics
1.9.1 Amdahl Law: The main idea is that when we accelerate a part of the system, its effect on the overall performance of the system depends on the importance and acceleration of that part.
1.9.2 Concurrency and parallelism:
Concurrency refers to a system that has multiple activities at the same time, and parallelism refers to making a system run faster with concurrency.
1.9.3 the importance of abstraction in computer systems
1.10 Summary
Information is the bit + context;
The program is translated into different formats by other programs: preprocessor, compiler, assembler, linker Four stages of the process;
The processor reads and interprets the instructions stored in memory;
Storage device hierarchy: CPU registers at the top, followed by multilayer hardware cache memory, DRAM main memory and disk memory;
Operating system kernel Three basic abstraction: The file is the abstraction of the I/O device, the virtual memory is the abstraction of main storage and disk, the process is the abstraction of processor, main memory and I/O device;
The network provides a means of communication between computer systems.
Chapter One computer system roaming