System Programming Knowledge Summary

Source: Internet
Author: User

1.Linux Operating System

Multi-user

2.shell

Command line interpreter consumer <--> core

Interpreted type rather than compiled

Run Program Fork Child process EXECV function cluster Replace user-specified program wait process end

3.vim, gcc/g++ (using dynamic libraries by default at compile time), GDB, make ($foreach <var>,<list>,<text>), CATGS

4. Environment variables

command echo, export, env, set

5. Common commands

6. files (functions of file attributes and operation files)

File type: Normal file (-), catalog file (d), Pipeline file (p), device file (b C),

Socket (s), linked file (l)

File information: stat (), Fstat (), Lstat () struct stat{};

File access permissions and related settings:

Each file has 9 access bits CHOMD command, umask function (file mode creates a mask word, returns without error)

Set file uid and GID, chown

File system

Hard Link ln Source file destination file link ();

Soft link ln-s source file destination file symlink ();

File time: St_atime, St_mtime, St_ctime

7. File i/0

File descriptor

Open (), read (), write (), Lseek (), Close ()

DUP ()

8. Standard I/O Library

standard input, standard output, standard error

Buffer

9. Process Environment

Main () function

Command-line arguments

Process termination

Environment tables and environment variables

C-language storage space layout

10. Process Control

pid_t getpid (void);

Process concept: A running program, its basic two elements are program code and program associated data set

Pcb:linux is called task_struct, which holds information about the process and can be understood as a collection of process properties

Process identifiers: Each process is represented by a unique non-negative integer type

Ppid, UID, GID, Euid, egid, can be obtained by corresponding function

Change user ID and Group Id:setuid () Setgid ()

Status of the process: R S D (disk sleep state) T T Z X

Priority: Ps-l command PRI the smaller the value of this column, the sooner the process is executed NI represents the nice value of the process, PRI (new) =pri (old) +nice

Process creation: fork (), vfork () zombie process, orphan process

Process wait: Wait (), Waitpid ()

Process program substitution: exec ()

Process termination: 8 kinds

5: Return from the main function, Exit in any thread (), call _eixt () or _exit (), go back from the last thread, call the last thread Pthread_exit

3: Call abort function, last thread responds to cancellation request, receives termination signal

11. Inter-Process relations

Terminal login, Terminal control

Process groups, sessions, jobs

12. Signal

Signal concept: A signal is a technique that notifies a process that a situation has occurred

How the signal is produced: three kinds

Signal blocking and recursion: recursive, pending signal set operation function change or read signal mask read pending signal set

Capture of Signals

reentrant functions

callback function

Race condition: Error caused by timing problem

The signal mechanism is stored in the PCB

13. Threading Control

pthread_t pthread_self (void);

Concept: Sometimes you need to execute multiple control flows in one process

The difference from a process: a thread is an execution branch running in a process that is the basic unit of a resource allocation, a fundamental element of a thread dispatch, a process that emphasizes exclusivity, and a thread that emphasizes sharing

Line programming: thread creation, thread termination, thread waiting

The thread function in return, Pthread_exit (void*) terminates itself, int pthread_cancle (pthread_t) cancels other threads in the unified process), and if any one of the threads calls exit or _exit, Then all threads of the entire process are terminated

Thread separation: The default state is set to a binding, but it can be set to detach state

Thread synchronization: Mutex (possibly deadlock), condition variable (typical example producer consumer model), POSIX semaphore (producer consumer model based on ring BUF), read-write lock

Thread-Private data:

Thread safety and Reentrant functions:

14. Inter-process communication

Four cases of end write end of pipe one-way communication

FIFO Creation (MKFIFO)

Message Queuing

Signal Volume

Shared memory

15. Daemon Process



This article is from the "Zero Egg" blog, please be sure to keep this source http://lingdandan.blog.51cto.com/10697032/1771991

System Programming Knowledge Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.