PCBプロセス制御ブロック


include/linux/sched.h
struct task_struct {
 volatile long state;
 struct thread_info *thread_info;
 atomic_t usage;
unsigned long flags;
unsigned long ptrace;
 
 int lock_depth;
 
 int prio, static_prio;
 struct list_head run_list;
 prio_array_t *array;
 
 unsigned long sleep_avg;
 long interactive_credit;
 unsigned long long timestamp;
 int activated;
 
 unsigned long policy;
 cpumask_t cpus_allowed;
 unsigned int time_slice, first_time_slice;
 
struct list_head tasks;
 struct list_head ptrace_children;
 struct list_head ptrace_list;
 
 struct mm_struct *mm, *active_mm;
...
 struct linux_binfmt *binfmt;
 int exit_code, exit_signal;
 int pdeath_signal;
...
 pid_t pid;
 pid_t tgid;
...
struct task_struct *real_parent;
struct task_struct *parent;
struct list_head children;
 struct list_head sibling;
 struct task_struct *group_leader;
...
 struct pid_link pids[PIDTYPE_MAX];
 
 wait_queue_head_t wait_chldexit;
 struct completion *vfork_done;
 int __user *set_child_tid;
 int __user *clear_child_tid;
 
 unsigned long rt_priority;
 unsigned long it_real_value, it_prof_value, it_virt_value;
 unsigned long it_real_incr, it_prof_incr, it_virt_incr;
 struct timer_list real_timer;
 unsigned long utime, stime, cutime, cstime;
 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
 u64 start_time;
...
 uid_t uid,euid,suid,fsuid;
  gid_t gid,egid,sgid,fsgid;
 struct group_info *group_info;
 kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
 int keep_capabilities:1;
 struct user_struct *user;
...
 struct rlimit rlim[RLIM_NLIMITS];
 unsigned short used_math;
 char comm[16];
...
 int link_count, total_link_count;
...
 struct fs_struct *fs;
...
 struct files_struct *files;
...
 unsigned long ptrace_message;
 siginfo_t *last_siginfo;
...
 };

スケジューリングデータメンバー:1)vo latile long stateはプロセスの現在の状態を表します.プロセスが実行されると、状況に応じてステータスが変更されます.プロセス状態は、TASK RUNN ING(運転可能状態)、TASK INTERUPT IBLE(割り込み可能な待機状態)、TASK UNITERRUPT IBLE(割り込み不可能な待機状態)、TASK ZOMB IE(硬直状態)、TASK STOPPED(一時停止状態)の5種類である.2)long pr io rityプロセス優先度,prio rityの値はプロセスがCPUを取得するたびに使用できるタイムスライス長(単位はjiffies)を与える.3) unsigned long rt_priority rt_priorityの値はリアルタイムプロセスの優先度を与え、rt_priority 1000は、プロセスがCPUを取得するたびに使用可能なタイムスライス長(単位はjiffies)を与える.4)long counterは、ローテーションスケジューリング時にcounterは、現在のプロセスがどのくらい実行できるかを示します.プロセスの開始時にpriorityの値が付与され、その後、クロックごとに1が中断され、0に減少すると、新しいスケジューリングが発生します.5)unsigned long policyは、プロセスのプロセススケジューリングポリシーを表す.スケジューリングポリシー:SCH ED_OTHER 0は,非リアルタイムプロセスであり,優先度に基づくローテーション法を用いる.SCH ED_FIFO 1,リアルタイムプロセス,先進的な先出しアルゴリズムを用いる.SCH ED_RR 2,リアルタイムプロセス,優先度ベースのローテーションプロセスキューポインタ:1)struc t task_struct* next_task, * prev_taskはLinuxのすべてのプロセス(PCBの形式で)で双方向チェーンテーブルを構成し、next_taskとprev_taskはチェーンテーブルの前後方向ポインタです.2) struct task_struct* p_opptr, * p_pptr struct task_struc t* p_cptr, * p_ysptr, * p_osptr以上は、プロセスの元の親プロセス、親プロセス、サブプロセス、および新しい兄弟プロセスを指すポインタです.3) struct task_struct* pidhash_next struct task_struct** pidhash_pprevは、プロセスhashテーブルの前後ポインタをチェーンするために使用されます.システムプロセスは双方向チェーンテーブルに加えてhashテーブルに追加される.プロセスID:uid_t uid  gid_t gid uidおよびgidは、それぞれ実行プロセスのユーザ識別およびユーザグループ識別である.pid_t pid  pid_t pgrp pidとpgrpは、それぞれ実行プロセスのプロセス識別番号とプロセスグループ識別番号の時間データメンバーである:long per_cpu_utime [ NR_CPUS ] per_cpu_stime [ NR_CPUS] per_cpu_utimeはユーザ状態プロセスが実行された時間であり、per_cpu_ stimeはカーネル状態プロセスが実行する時間プロセス作成時間unsigned long start_timeファイルシステムデータメンバー:struct fs_struct*fs fsは、プロセス自体とVFS(仮想ファイルシステム)との関係情報を保存します.struct fs_struct {  atom ic_t count;  rw lock_t lock;  int umask;  struct dentry* root, * pwd, * altroot;  struct vfsm ount* rootmnt, * pwdmnt, * altrootmnt; } root、rootm ntはルートディレクトリのdentryとそのmountポイントのvfsmountです.pwd、pwdmntは、現在の作業ディレクトリのdentryとそのmountポイントのvfsです.mount.Altroot,altrootmntは,ルートノードが置換された後の元のルートターゲットのdentryとそのmount点を保存するvfsmountである.メモリデータメンバー:1)struct mm_struct*mm Linuxでは、プロセスのメモリ要件をオンデマンドでページングするポリシーを採用しています.task_structのデータメンバーmmは、ストレージ管理に関するmm_を指すtruct構造.2) struct mm_struct* active_mm active_mmはアクティブアドレス空間を指す.3) mm_segm ent_t addr_ lim itはスレッド空間アドレスを表す.ユーザスレッド空間アドレス:0..0xBFFFFFFF. カーネルスレッド空間アドレス:0..0xFFFFFFFF 4) spinlock_t alloc_ lockは空間を申請する際に使用されるスピンロックに使用される.スピンロックの主な機能は臨界領域保護である.ページ管理:1)int swappable:1プロセスが占有するページを取り替えることができるか.swappableが1の場合は交換可能です.2) unsigned long min_flt, maj_ fltこのプロセスはminor欠ページ回数とmajor欠ページ回数を累計します.3)unsigned long nswapこのプロセスはページ数を累計する.4) unsigned long swap_cnt次のループで最大交換可能なページ数.