Linux Common Commands
- The Groups command knows which user groups they belong to.
- The chmod command modifies the permissions of the file.
- The command to find the files created in the home directory the day before yesterday is find ~-ctime 2
- The ZIP command uses the- e parameter to create an encrypted compressed package.
- Ls. | The function of the sort command is to display the contents of the current directory and sort it.
- Using grep to find the main function in the current directory *.c the command in that file is grep main *.c
- The command for a few lines of code using WC statistic hello.c is: wc-l hello.c
- The command output redirection command that displays the results of the current directory in the LS command is ls.txt: ls > Ls.txt
- The Tee command can be redirected to multiple files at the same time.
- CTRL + A shortcut key function is: Move the cursor to enter the wardrobe, equivalent to the home button.
- The command to force the test file to be deleted is: rm-f test.
- There is a linear lookup algorithm in the data structure, the C standard library does not have this function, but in Linux, this function is: Lfind or Lsearch
- The find command that finds all directories under the current directory is: Find. -type D
- The command to find the value of the macro Stdin_fileno is: Grep-nr xxx/usr/include
- The most basic four abstractions in the operating system are: virtual machines, processes, virtual storage, files.
- The two main tasks of the linker are: symbolic parsing and relocation.
- The loader maps the contents of the executable file to the storage and runs the program.
- The command to display file properties (status) in Linux is stat
- The command to sort directories or files in the current directory by using the du command is: Du-sk *| Sort-rn
- VI see the shortcut keys for the Help document for function qsort (K)
- Abstraction is an important concept in CS, in which the instruction set structure provides an abstraction of the actual processor.
- The pic in gcc-f pic xxx.c means: Location-independent code.
Vim
- Vim editor, commonly used in three modes: Normal mode, insert mode and command line mode. You need to be familiar with the switching modes between the three modes:
- Normal → insert: I or a
- Insert → normal: ESC or Ctrl + [
- command line → Normal: ESC or Ctrl + [
GCC
Common options:
- -C compiles only the non-linked, generating the target file. O
- -S compiles no assembly, generates assembly code
- -E only precompiled, no other processing
- -G contains standard debug information in an executable program
- -o file to designate file files as output files
- -V Prints the command line information and compiler version of the compiler's internal compilation procedures
- -I dir add the dir directory to the search path list of the header file
Compile process:
- Pretreatment: Gcc–e hello.c–o hello.i; "-O" means the target file, and the ". I" file is a pre-processed C program.
- Compilation: Gcc–s hello.i–o Hello.s; The "-S" option compiles only without assembly, resulting in assembly code.
- Compilation: Gcc–c Hello.s–o hello.o; ". S" file into destination file
- Link: gcc hello.o–o hello; Gcc-o call ld** to create executable target file
- -O is followed by the name you specified for the generated file, and if not specified, the default is A.out
gdb
- Use GCC to compile with "-G" parameter before GDB can be debugged
- The most basic commands of GDB are:
- GdB Programm (Start gdb)
- L View the files that are loaded
- B Set Breakpoints
- Info B View Breakpoint Condition
- Run starts running the program
- BT Print function Call stack
- P View variable values
- C continue running from the current breakpoint to the next breakpoint
- N Single Step operation (no entry)
- S Single Step operation (enter)
- Quit Quit GDB
Four types of breakpoints:
- Line breakpoint: b [number of rows or function name] < conditional expression >
- function Breakpoint: b [function name] < conditional expression >
- Conditional breakpoint: b [number of rows or function name] <if expression >
- Temporary breakpoint: tbreak [number of rows or function name] < conditional expression >
Make
and Makefile
- Make engineering manager is an "automatic compilation manager", where "automatic" refers to the ability to automatically discover updated files based on file timestamps and reduce compilation effort, while it performs a lot of compilation work by reading the contents of the makefile file.
- Makefile is the only configuration file that make reads into
- In a makefile, it usually contains the following content:
1, need to be created by the Make tool target body, usually executable files and target files, can also be performed actions, such as ' clean ';
2. The files to be created by the target body depend on, usually the other files needed to compile the target file.
3. The command to run when creating each target body, which must start with TAB tab
- There are two ways to define a variable in makefile:
Recursive expansion mode (Var=var).
Simple Way (Var:=var).
- The use of variables in make is in the format: $ (VAR).
Regular expressions
Rules:
- \ special symbol, which indicates the following character itself
- [] matches any of these characters, but each match matches only one
- [^] matches any character except one, and each match matches only one
- {n} number of times decorated, repeat n times, as follows:
? = {0,1}
+ = {1,}
*= {0,}
{M,n}: At least m, up to N
^ Match from where the string starts
$ match from where the string ends
| Can match left or right
representation and processing of information
- Numeric representation: Unsigned, complement, floating point number.
- Byte order is the basis of network programming. Small-End Method-stores the object in memory in the order from the least significant byte to the most significant byte. The big-endian--stored sequentially from the highest valid byte to the lowest valid byte.
- Binary values are the core of computer coding, storing, and manipulating information (0, 1).
- The computer representation of a signed number: a positive complement = the original code. The complement of negative number = The original code you take the reverse and add 1.
- The bit representation of the extended number: 0 extension, Symbol extension.
IEEE floating point representation:
- To represent a number in the form of V = ( -1) s * M * 2E:
- Symbol: s Determines whether the number is negative (s = 1) or positive (s = 0), while the symbolic bit interpretation for the value 0 is handled as a special case.
- Mantissa: M is a binary decimal that has a range of 1 to 2-ε, or 0 to 1-ε.
- Order code: The role of E is weighted to the floating point data, which is 2 of the power of the E (possibly negative).
- Divide the bit representation of a floating-point number into three fields and encode the values:
- A separate sign bit s directly encodes the symbol S.
- The Order field of K-bit exp = EK-1...E1E0 encoded Order E.
- The N-bit decimal segment Frac = fn-1...f1f0 encodes the mantissa m, but the encoded value also depends on whether the value of the Order field equals 0.
- Two common formats: single-precision floating-point format float and double-precision floating-point format double.
machine-level representation of the program
- For machine-level programming, two important abstractions are: ISA, virtual address.
- gcc-s Xxx.c-o Xxx.s obtains the assembly code,gcc-c xxx.c-o XXX.O produces the target file, in binary format. can also be disassembled with objdump-d XXX.O . 64-bit machine want to get 32 code: Gcc-m32-s xxx.c. There is no objdump in MAC OS, there is a basic equivalent command otool.
- Three variants of the data transfer instruction: MOVB transmit byte, MOVW transfer Word, MOVL transmit double word.
- Conditional expressions in the C language are implemented in the Assembly in conjunction with conditional jumps and unconditional jumps.
- The loop structure in C language can be combined with conditional testing and jump.
- In the IA32 directive, three types of operands are: immediate count, register, memory.
- Effective address calculation imm (eb,ei,s) = Imm + R[eb] + r[ei]*s
- %esi%edi can be used to manipulate the array,%esp%EBP is used to manipulate the stack frame.
- Stacks are used to pass parameters, store return information, save registers, and store locally.
- In the Linux assembly, the statement that forms the stack frame for air conditioning is the push%ebp movl%esp%ebp.
- In the Linux assembly, the function has a return value in the%EAX register.
Transfer control:
1. The call command has a target, which indicates the address of the instruction to be invoked at the beginning of the process, and the effect is to return the address to the stack and jump to the beginning of the called process.
2. The RET command pops the address from the stack and jumps to this location, using the command stack pointer to point to the location where the call command stores the return address.
Processor Architecture
- ISA: Instruction set architecture-byte-level encoding of instructions and instructions supported by a single processor.
- HCL: Hardware Control Language-a simple language that describes the control part of a hardware system. The processor for
- Y86 has 8 program registers,%EAX,%ECX,%EDX,%EBX,%ESI,%EDI,%ESP,%EBP. The only tool that
- creates Y86 code is the assembler. The MOVL instruction of the
- IA32 is divided into 4 different instructions: IRMOVL,RRMOVL,MRMOVL,RMMOVL indicates the source and destination format respectively. The source can be an immediate number (i), register (R), or memory (m). The first letter of the instruction name indicates the type of the source, and the second letter indicates the destination type. The object operand can be: Register (R), memory (m) .
- 4 integer operations directives: Addl, Subl, Andl, Xorl. They operate on register data only, and IA32 also allows these operations on the memory data. These instructions will set up three condition codes: ZF, SF, of.
- 7 Jump commands: jmp, Jle, JL, je, jne, Jge, JG
- 6 Conditional delivery directives: Cmovle, CMOVL, Cmove, Cmovne, Cmovge, CMOVG. The format of these instructions is the same as the register-transfer instruction RRMOVL, but the value of the destination register is updated only if the condition code satisfies the required constraint. The
- call instruction returns the address to the stack, and then jumps to the destination address, which is returned by the RET instruction from such procedure calls. The
- PUSHL and POPL directives implement both the in and out stacks. The
- halt instruction stops the execution of the instruction. There is an equivalent directive HLT in the IA32. Executing the halt instruction will cause the processor to stop and set the status code to HLT. The IA32 application does not allow this instruction because it causes the entire system to pause. The
- Stat describes the overall state of the program execution:
Value name meaning
1 AOK normal operation
2 HLT processor executes halt instructions
3 ADR encounters an illegal address
4 INS Encountering illegal instructions
- Implementing a digital system requires three components: combinational logic, memory elements, and clock signals.
- Y86, use the clock register to save the program counter PC, Condition code cc, and program status Stat.
- In Y86, instruction execution is divided into six stages: Refer, decode, execute, visit, write back, update pc.
Memory Hierarchy
- A memory system is a hierarchical structure of storage devices with different capacities, costs, and access times.
- The central idea of the storage hierarchy is that the upper layer acts as the underlying cache .
- Cache memory: As a cache area between CPU and main memory
- locality principle : A well-written computer program often tends to refer to data items that are adjacent to other recently referenced data items, or to the data item itself that has recently been referenced. Locality has two forms of temporal locality and Spatial locality .
- Random access memory (Ram) is divided into two categories: static RAM (SRAM), dynamic Arm (darm).
- According to the carrying signal, the bus can be divided into data bus, address bus, control bus three kinds.
- The CPU uses memory-mapped I/O technology to issue commands to I/O devices.
- Access time to disk sectors consists of three parts: seek time, rotation time, transfer time .
- The logical block number of a logical disk block can be translated into a disk, a track, a sector ternary group.
- formula for calculating disk capacity: Disk capacity = Bytes/sector x average number of disks/track x number of tracks/surface x surface number/disc x number of discs/disk
- A simple principle of locality in a program:
1, repeated reference to the same variable program has a good time locality.
2. For a program with a reference pattern with a step size of K, the smaller the step size, the better the spatial locality.
3, for taking orders, the cycle has a good time and spatial locality. The smaller the loop body, the more the loop iteration number, the better the locality.
Cache Hits:
When a program needs a data object D in Layer k+1, first look for D in a block that is currently stored in the K layer, and if D is just cached in the K layer, it is called a cache hit. The program reads D directly from level K, faster than reading d from the k+1 layer.
Cache misses:
That is, there is no cached data object D in Layer K. The K-tier cache then extracts the block containing d from the k+1 cache. If the level K cache is full, an existing block may be overwritten.
The substitution policy controls that decide which block to replace and cache, such as the random substitution policy, have recently been used at least by the LRU substitution policy.
Types of Cache Misses:
1, mandatory not hit/cold not hit
The level K cache is empty (known as a cold cache), and any access will not be hit. This is usually a brief event.
2. Conflict not hit
The placement policy is to place the block limit of the k+1 layer in a small subset of the K-layer blocks.
3, capacity is not hit
When the size of the working set exceeds the size of the cache, the cache undergoes a capacity miss, which means that the cache is too small to handle the working set.
The cache structure can be described by tuples (s,e,b,m):
- S: There are s=2^s cache groups in this array
- E: Each group contains an E cache line
- B: Each row is made up of a b=2^b byte block of data
- M: Each memory address has a M-bit, which forms m=2^m different address
- Valid bits: Each row has a valid bit that indicates whether the row contains meaningful information
- Mark bit: t=m-(b+s), unique identifier of the block stored in this cache line
- Group Index bit: s
- Block Shift: B
- The cache structure divides m addresses into T-markers, S-group index bits, and B-block offsets.
- Cache size/Capacity C refers to the size of all blocks and does not include the tag bit and the valid bit, so:c=s*e*b
Your own harvest.
I feel the third chapter, the fourth chapter, the fifth chapter, the sixth chapter content, the book looks relatively solid, may have some hard knowledge not to remember in the mind, the soft knowledge grasps has certain confidence. When just learned a new knowledge of the time feel very "deep", can master the new problems naturally come, feel not "deep". Perhaps this is called "deep understanding of computer systems". Perhaps this is self-taught to bring me a learning mode bar.
Their own lack of
Too much attention to "reading", do not pay attention to the actual operation of the Linux virtual machine, GCC, GDB, the use of not very skilled. Not as "Liangshan heroes before" and when the "Liangshan heroes" after the study effect is very different, it seems that the teacher's "hero" list for me is very useful, but also from the side of the reflection of their own learning initiative is not very strong, to self-reflection, now although out of the area to pass, after a week to write two blog post.
Course Suggestions and comments
Feel the weekly test questions, for the knowledge of the book is not very deep, a little shallow, read reading can answer up, I hope the teacher to examine some of the depth of knowledge. If the inspection quality is raised, the test is the reflection of the learning situation.
20145235 Interim Summary of the basic design of information security system