Linux-unix System Programming Manual Learning notes __HTML5

Source: Internet
Author: User
Tags message queue posix semaphore

Linux-unix System Programming Manual Learning notes

--michael Kerrisk

1. Linux proprietary programming Features:

⑴epoll, a mechanism for obtaining file I/O event notifications.

⑵inotify, a mechanism for monitoring file and directory changes.

⑶capabilities, a mechanism that gives a process a partial privilege for a superuser.

⑷ Extended Properties.

⑸i-node tag.

⑹clone () system call.

⑺/proc file System.

⑻ Linux's proprietary implementation details in file I/O, Signals, timers, threads, shared libraries, interprocess communication, and sockets.

2. The process communication and communication mechanism under Linux mainly includes:

⑴ Pipelines (Pipe) and well-known pipelines (named Pipe): Pipelines can be used for communication between relational processes, which overcomes the limitations of pipe without name, and therefore allows communication between unrelated processes, in addition to the functionality of a pipe;

⑵ Signal (Signal): A signal is a more complex form of communication used to inform the receiving process that an event occurs, in addition to communication between processes, the process can send signals to the process itself; Linux in addition to supporting the UNIX early signal semantic function Sigal, It also supports the signal function sigaction of semantics conforming to POSIX.1 standard (in fact, the function is based on BSD, BSD in order to achieve reliable signal mechanism, but also can unify the external interface, with the Sigaction function to realize the signal function);

⑶ Message Queue (Message Queuing): The messages queue is a linked table of messages, including POSIX Message Queuing system V Message Queuing. A process with sufficient permissions can add messages to the queue, and processes that are given Read permission can read messages in the queue. Message Queuing overcomes the lack of information load, the pipeline can only host unformatted byte streams and buffer size limitations.

⑷ Shared Memory: Enables multiple processes to access the same memory space, which is the fastest available form of IPC. is designed for the low efficiency of other communication mechanisms. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and mutual exclusion between processes.

⑸ Semaphore (semaphore): primarily as a means of synchronization between processes and between different threads of the same process.

⑹ sockets: A more general interprocess communication mechanism that can be used for interprocess communication between different machines. Originally developed by the BSD branch of the UNIX system, it is now generally possible to migrate to other Unix-like systems: Linux and System V variants support sockets.

⑺ file Locking: Allows a process to lock parts of a file to prevent other processes from reading or updating the contents of the file.

3.4 major system calls to perform file I/O operations:

The ⑴fd=open (pathname,flags,mode) function opens the file identified by pathname and returns a file descriptor for the open file in the subsequent function call. If the file does not exist, the open () function can be created, depending on the settings for the bitmask parameter flags. The flags parameter can also specify how the file should be opened: read-only, write-only, or read-write. The mode parameter specifies the access to create a file by an open () call, and the Mode argument can be ignored if the open () function does not create a file.

The ⑵numread=read (fd,buffer,count) call reads up to count bytes of data from an open file that is referred to by FD and is stored in buffer. The return value of the read () call is the number of bytes actually read. If no more bytes are readable, the return value is 0.

⑶numwritten=write (Fd,buffer,count) invokes data that reads as many as count bytes from the buffer into an open file that is referred to by FD.    The return value of the write () call is the number of bytes actually written to the file, and may be less than count. ⑷status=close (FD) calls Close () after all input/output operations are completed, releasing the file descriptor FD and associated kernel resources.

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.