"Linux Advanced Programming" (Chapter 11th) System v interprocess communication 1

Source: Internet
Author: User
Tags unique id

System V, once also known as the T System V, is one of many versions of the UNIX operating system.

Traditionally, System V is considered one of two Unix flavors (the other is BSD). However, with the advent of UNIX implementations that are not based on both codes, such as Linux and QNX, this generalization is no longer accurate.

System V IPC Basics

The IPC mechanism of system V consists of 3 mechanisms: Message Queuing , semaphore , and shared memory .

The ipcs command in the shell can view the IPC tools that are being used in the current system.

IPCRM command in the shell: manually delete an IPC mechanism.

ID value : Each IPC mechanism is assigned a unique ID value, using the ID value to operate on the IPC mechanism.

Key value : 32-bit integer. Two processes cannot access each other's space arbitrarily, that is, when one process creates an ID value, another process cannot get it. To do this, the IPC convention is created using the key value as the parameter, and the same key value will get the ID of the same IPC object.

To prevent all programs from using the same key value, use the Ftok () function to create a key value

  key_t Ftok (__const char *__pathname, int __proj_id) : The first parameter is a pathname, the second argument is an int variable

The 第31-24位 of the key value, which is a low 8-bit for the Ftok 2nd parameter

The 第23-16位 of the key value, the lower 8 bits of the file's St_dev property

The 第15-0位 of the key value, the lower 16 bits of the file's St_ino property

31--> 0 The first few are defined in this order

owner and Authority : IPC access rights with IPC tools are defined as struct ipc_perm in/usr/include/bits/ipc.h

"Linux Advanced Programming" (Chapter 11th) System v interprocess communication 1

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.