Read pid.h

at first

I think there are many mistranslations, so I would be grateful if you could point out any concerns.

Purpose

--Read the code for the time being --Understanding the structure of PID ――I will do my best in English

Source

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/pid.h

Main subject

/* SPDX-License-Identifier: GPL-2.0 */

Source code license. You are free to modify, sell, or publish this source code. Instead, make the source code GPL licensed as well. And that

#ifndef _LINUX_PID_H
#define _LINUX_PID_H

It's used to determine if the header is used.

#include <linux/rculist.h>
#include <linux/wait.h>
#include <linux/refcount.h>

enum pid_type
{
	PIDTYPE_PID,
	PIDTYPE_TGID,
	PIDTYPE_PGID,
	PIDTYPE_SID,
	PIDTYPE_MAX,
};

~~ List the types of pid ~~ Lists the types of objects to be identified by PID.

Not only the general process itself (distinguished by TGID), but also the process group (PGID) which is a mass of processes The session (SID) is also identified using PID.

I received a comment. I will understand it later.

/*
 * What is struct pid?
 *
 * A struct pid is the kernel's internal notion of a process identifier.
 * It refers to individual tasks, process groups, and sessions.  While
 * there are processes attached to it the struct pid lives in a hash
 * table, so it and then the processes that it refers to can be found
 * quickly from the numeric pid value.  The attached processes may be
 * quickly accessed by following pointers from struct pid.
 *
    ...
*/

Comment here. I will do my best to translate it into Japanese.

What is the structure "pid"? The structure "pid" is a kernel internal concept that identifies a process. Each refers to an individual task, process group, or session. The structure "pid" exists in the hash table while the process is attached, so you can quickly find the process from the value of the structure "pid" that it (hash table) references. Attached processes can be quickly accessed by pointers from the structure "pid".

I tried to translate everything into Japanese, but I noticed that it was inefficient, so I stopped. Will begin the main subject.

struct pid
{
	refcount_t count;
	unsigned int level;
	/* lists of tasks that use this pid */
	struct hlist_head tasks[PIDTYPE_MAX];
	/* wait queue for pidfd notifications */
	wait_queue_head_t wait_pidfd;
	struct rcu_head rcu;
	struct upid numbers[1];
};

/include/linux/refcount.h


//refcount_Definition of t
typedef struct refcount_struct {
	atomic_t refs;
} refcount_t;

/include/linux/list.h


//hlist_Definition of head
#define HLIST_HEAD_INIT { .first = NULL }
#define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }

I'm completely strayed, so I'll start over from the reference book.

Recommended Posts

Read pid.h
Read file
Read tz database
Read pandas data
Linux command [read]
Read PNG chunks
[SQLAlchemy] Read data
[python] Read data