- Mastering Linux Kernel Development
- Raghu Bharadwaj
- 344字
- 2021-07-08 09:47:21
Control groups (cgroups)
Cgroups are kernel mechanisms to restrict and measure resource allocations to each process group. Using cgroups, you can allocate resources such as CPU time, network, and memory.
Similar to the process model in Linux, where each process is a child to a parent and relatively descends from the init process thus forming a single-tree like structure, cgroups are hierarchical, where child cgroups inherit the attributes of the parent, but what makes is different is that multiple cgroup hierarchies can exist within a single system, with each having distinct resource prerogatives.
Applying cgroups on namespaces results in isolation of processes into containers within a system, where resources are managed distinctly. Each container is a lightweight virtual machine, all of which run as individual entities and are oblivious of other entities within the same system.
The following are namespace APIs described in the Linux man page for namespaces:
clone(2)
The clone(2) system call creates a new process. If the flags argument of the call specifies one or more of the CLONE_NEW* flags listed below, then new namespaces are created for each flag, and the child process is made a member of those namespaces.(This system call also implements a number of features unrelated to namespaces.)
setns(2)
The setns(2) system call allows the calling process to join an existing namespace. The namespace to join is specified via a file descriptor that refers to one of the /proc/[pid]/ns files described below.
unshare(2)
The unshare(2) system call moves the calling process to a new namespace. If the flags argument of the call specifies one or more of the CLONE_NEW* flags listed below, then new namespaces are created for each flag, and the calling process is made a member of those namespaces. (This system call also implements a number of features unrelated to namespaces.)
Namespace Constant Isolates
Cgroup CLONE_NEWCGROUP Cgroup root directory
IPC CLONE_NEWIPC System V IPC, POSIX message queues
Network CLONE_NEWNET Network devices, stacks, ports, etc.
Mount CLONE_NEWNS Mount points
PID CLONE_NEWPID Process IDs
User CLONE_NEWUSER User and group IDs
UTS CLONE_NEWUTS Hostname and NIS domain name
- PostgreSQL技術(shù)內(nèi)幕:事務(wù)處理深度探索
- Visual Basic程序設(shè)計(jì)(第3版):學(xué)習(xí)指導(dǎo)與練習(xí)
- INSTANT MinGW Starter
- Learning Laravel 4 Application Development
- Java程序設(shè)計(jì)
- Active Directory with PowerShell
- Android系統(tǒng)級深入開發(fā)
- C語言程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo) (第2版)
- Yii Project Blueprints
- 大學(xué)計(jì)算機(jī)基礎(chǔ)
- HTML5+CSS3+jQuery Mobile APP與移動網(wǎng)站設(shè)計(jì)從入門到精通
- Mastering Docker
- PHP+MySQL動態(tài)網(wǎng)站開發(fā)從入門到精通(視頻教學(xué)版)
- Java多線程并發(fā)體系實(shí)戰(zhàn)(微課視頻版)
- Learning Alfresco Web Scripts