SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
8 A
1. 0 1., 2 1 2 1
/ 2/ , 5 44 201 8 /8/ /.
• ed 8
• R@ I
• a
• cg A @
• c c gd t l
• c efho t Rs
• t c gd = I
• t i a
• 81 . , 8 3 81 . . ., 82 t
• c xu t i a Rs A
• efho n
• i a c rv
.8 2.: , 33 2018 . . :.
• 02 8 I RA L R A
cd
• I
• a e
• I
0 2 11 0. 4 4 ,
• .: C I c il
• A 8: C 4 2 5A : C
• ,/1 .: 2 G il
• A 8 C 8 A 7 2 : 4 A 2 5
• aI Rnv otRghm I I fsL U
• I I Rbd r U
• .: C Rpue UN
0 : 2 4 :8 A A 5
•
• 0268A L
•
•
•
• R a
• I
•
0 2 11 0. ,
( 0 0 - 7. ) 2 0 0 0
• 18
• A
I
• A I
• 18
• 18 ,18 R
#include <stdio.h>
#include <unistd.h>
int main() {
pid_t pid = fork();
// forkA
if (pid == -1) {
printf("Fork failed¥n");
//
} else if (pid == 0) {
printf("Child process, pid: %d¥n",
getpid());
//
} else {
printf("Parent process, pid: %d¥n",
getpid());
}
}
$ gcc fork_sample.c && ./a.out
Parent process, pid: 72390
Child process, pid: 72391
0 A: 2 . 4# A:8 A A 5#
• , 8: #4 A 2 5 : (# A 7 A #4 / )
• 17 A RL15 17 A I
#ifdef __ARCH_WANT_SYS_FORK
SYSCALL_DEFINE0(fork)
{
#ifdef CONFIG_MMU
return _do_fork(SIGCHLD, 0, 0, NULL, NULL, 0);
#else
/* can not support in nommu mode */
return -EINVAL;
#endif
}
#endif
•
• 02 8A L
•
•
•
• R a
• I
•
9 0 2 11 0. ,
8 8 << 8 8 8
• .-0 8 GT
• I G.-0 O S
• NP
• AC1 8
• , .1
• ,.1 ,2 < GLR
). 1. ( , 1 0 8 .8. .
• 0 . , . .
I
• 0 . 2 1 I R A
#include <stdio.h>
#include <pthread.h>
void* print_doubled(void *x) {
int *ix = (int *)x;
printf("%d¥n", *ix * 2);
}
int main() {
pthread_t th;
int x = 100;
int ret = pthread_create(
&th, NULL, print_doubled, (void *)&x);
if (ret != 0) {
printf("thread execution failed");
return 255;
}
pthread_join(th, NULL);
return 0;
}
$ gcc -lpthread pthread_sample.c
$ ./a.out
200
( (
# 2 : 2 / 70 66 : :2 2: 21
• 7 6 :2/1.0:2/ 2 0 , #
• R
• 72 :2/1 I 1
• / : :2/1. :2/1./ :
• /: .:8 72 I A LR
• /: /: .:8 72 R
int
__pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
( (
2 , ) (33 201 8 8 .
• 1 ,. 8 , 2 , 0 A
• , 1 ,. 1 ,.
int
__pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg)
{
const struct pthread_attr *iattr = (struct pthread_attr *) attr;
struct pthread *pd = NULL;
int err = ALLOCATE_STACK(iattr, &pd);
/* */
pd->start_routine = start_routine;
pd->arg = arg;
/* */
*newthread = (pthread_t) pd;
/* */
int retval = create_thread(pd, iattr, ...);
return retval;
}
8 8 / # A 8A8 87# (
• A A78 A C E A A CE 8 8 8 7# 0()
• ,.4,021 A A4 8 R HN O IL
static int
create_thread (struct pthread *pd, const struct pthread_attr *attr,
bool *stopped_start, STACK_VARIABLES_PARMS, bool *thread_ran)
{
/* */
const int clone_flags = (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SYSVSEM
| CLONE_SIGHAND | CLONE_THREAD
| CLONE_SETTLS | CLONE_PARENT_SETTID
| CLONE_CHILD_CLEARTID
| 0);
/* */
ARCH_CLONE(&start_thread, STACK_VARIABLES_PARMS, clone_flags, pd, &pd->tid, tp,
&pd->tid);
/* */
return 0;
}
0 A: 2 . 4# A:8 A A 5# )
• , 8: #4 A 2 5 : (# A 7 A #4 /
• 14 15 17 A L I
SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
int __user *, parent_tidptr,
int __user *, child_tidptr,
unsigned long, tls)
{
return _do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr, tls);
}
) ) (
I GEA H: 0C EA GF E F EH
• N LM _ O DC > : FO
• TV 60. 1
• RS 1 , 82 1 , -6 1 , -01,6 1 , ,
M I : /D IH H
• IIFH D LAC EH D AF IC 0 C:D F: H C:D ED IC
• 0 2, 81
• Rx mtedV mted Sop u
• 0 2, -
• Rx mtedV mtedP S rcdhn v T
• 0 2, -/0,
• Rx mtedV mted ri_da m hNlr v T
• 0 2, 7. ,
• mted Rx mtedV Sdsgj rNm O
# . / , 1 77 45 2
/*
* cloning flags:
*/
#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
#define CLONE_VM 0x00000100 /* set if VM shared between processes */
#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
/* */
#define CLONE_NEWPID 0x20000000 /* New pid namespace */
#define CLONE_NEWNET 0x40000000 /* New network namespace */
#define CLONE_IO 0x80000000 /* Clone io context */
• 5 4 5 0 1:8 : /72 7 A 07:0 17 2 / 7 A 15 2 5
• L 0
• I 0 4 /7
8 , ) ( 8 12 9 8 9 8 .
• _ Ied 0 8 R A
• Ied R A
• I R . 0 8
• ed fcI ag
•
• 1 R L
• I R
•
• IA
•
8 , 2 , 1 00 2 . 2, ,2 ,
# . A 7 / , 1 75 A 2
• AA 57A 0 1 : A / 2 7 0 0 8 4 8 1 #
• R I L
long _do_fork(unsigned long clone_flags,
unsigned long stack_start,
unsigned long stack_size,
int __user *parent_tidptr,
int __user *child_tidptr,
unsigned long tls)
# /5A 85 1 ,:: 8 7A 5 5 54
• 7AA 8A7 2 A 1:4 :8 2: 2 8 : 45 :8 754 7 .
• A1 90 A A aI b
• _ R L
struct task_struct {
struct thread_info thread_info;
volatile long state;
void *stack;
struct mm_struct *mm;
struct mm_struct *active_mm;
pid_t pid;
pid_t tgid;
/* Filesystem information */
struct fs_struct *fs;
/* Open file information */
struct files_struct *files;
/* c */
}
2 , ) ( 201 .
• I
A I
• ,3 , 3 I
R A 8
long _do_fork(unsigned long clone_flags,
unsigned long stack_start,
unsigned long stack_size,
int __user *parent_tidptr,
int __user *child_tidptr,
unsigned long tls)
{
struct task_struct *p;
/* */
p = copy_process(
clone_flags, stack_start, stack_size,
child_tidptr, NULL, trace, tls, NUMA_NO_NODE);
/* */
struct pid *pid = get_task_pid(p, PIDTYPE_PID);
long nr = pid_vnr(pid);
wake_up_new_task(p);
/* */
return nr;
}
0 A: 2 . 4# A:8 A A 5# (
• , 8: #4 A 2 5 :
(# A 7 A #4 / )
• 5 1 2 1 A 4
• m Rb hf o I
di a kr
• 4 1
• p Rh_ m
e
• nl e g c L
static struct task_struct *copy_process(
unsigned long clone_flags,
unsigned long stack_start,
unsigned long stack_size,
int __user *child_tidptr, ...)
{
struct task_struct *p; int retval;
/* s */
p = dup_task_struct(current, node);
/* s */
retval = copy_fs(clone_flags, p);
if (retval)
goto bad_fork_cleanup_files;
retval = copy_mm(clone_flags, p);
if (retval)
goto bad_fork_cleanup_signal;
/* s */
return p;
}
N # 4 I 8 . : I
• II I :EC IE 8 L E
A E A : /
• :E M7CCt mnpus diP
U R
• : I vx, 5
I8 A7 I :I ah e lbr
• e gh ,/21 7 0 oc
y V_ diPV_ Ok
rfe ,/21 7 0 oc y
V_ diP
static int copy_mm(unsigned long clone_flags,
struct task_struct *tsk)
{
struct mm_struct *mm, *oldmm;
/* */
oldmm = current->mm;
/* */
if (clone_flags & CLONE_VM) {
mmget(oldmm);
mm = oldmm;
goto good_mm;
}
mm = dup_mm(tsk);
good_mm:
tsk->mm = mm;
tsk->active_mm = mm;
return 0;
/* */
}
0 22 0. 6 6 ,
• A 61 6 8 a
• _ 2 R I A c
• d A
•
• 02 8A R
•
• R
• L I
•
0 7 2 11 0. 7 ,
• l Sd O l
• Sd O ah
• = i c I Ie n R ad
A
• ISd O g
8 . 1. , 22 1 0 . . .
( ( ) (
I , 28 8 4 0 # / 9: 8 8 87#
• : A . 9 : 5# 4 7
5 5 )# 8 8 :87 8#
1 ,(
• :3 abed
g RL :3
_ c
g R
static __always_inline struct rq *
context_switch(struct rq *rq,
struct task_struct *prev,
struct task_struct *next, /* h */)
{
struct mm_struct *mm, *oldmm;
mm = next->mm;
old_mm = prev->active_mm;
/* h */
if (!mm) {
/* h */
} else
switch_mm_irqs_off(oldmm, mm, next);
/* h */
switch_to(prev, next, prev);
barrier();
return finish_task_switch(prev);
}
) ( )
# /4 74A0 :2 ,88 7 6 4 4 A43 #
• 6 7 6 1 2 A083 87: 18 1 A 0 26 81 2 .
• R I L
void switch_mm_irqs_off(struct mm_struct * prev, struct mm_struct *next,
struct task_struct *tsk)
{
struct mm_struct *real_prev = this_cpu_read(cpu_tlbstate.loaded_mm);
if (real_prev == next) {
/* */
return;
} else {
/* */
}
/* */
}
8 . 1. 3, 22 1 0 . . .
• i a d R c
• a ge l nA I Sc
O h
• a
• 02 8 L R
• I
• R I
• R c
•
• A
30 2 11 30. 3 3 ,
0 0 ) . ( 23 0 0 0
• go 18 h A I nad . 8 0 h A I
R , . v I , 8,18
R
• nad x . 8 0fk l_A go s R
• nad i ltr s R c a go
L
• 18 u Ae I L i
/4A 74 0 - 2 ,:: 7 A 4 4 43
• da.7 g l
• .7 R bmLjihc
• AA 71 2 34 4: 4 9 8 :7 :71 0 : :7 24
0 0 4 4 A 7 34 A :
• .7
• AA 797 17A 7 4 2 :7 94 4: 4
• L e kI
• AA 3 0A4 0 4 8 0 0
1. 0 1., 2 1 2 1

Más contenido relacionado

La actualidad más candente

ELFの動的リンク
ELFの動的リンクELFの動的リンク
ELFの動的リンク7shi
 
Wireshark だけに頼らない! パケット解析ツールの紹介
Wireshark だけに頼らない! パケット解析ツールの紹介Wireshark だけに頼らない! パケット解析ツールの紹介
Wireshark だけに頼らない! パケット解析ツールの紹介morihisa
 
シェル芸初心者によるシェル芸入門
シェル芸初心者によるシェル芸入門シェル芸初心者によるシェル芸入門
シェル芸初心者によるシェル芸入門icchy
 
ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)
ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)
ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)NTT DATA Technology & Innovation
 
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/FallZabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/FallAtsushi Tanaka
 
std::pin の勘所
std::pin の勘所std::pin の勘所
std::pin の勘所Hiroaki Goto
 
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話Daichi Koike
 
CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...
CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...
CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...whywaita
 
雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニング雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニングyoku0825
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Taku Miyakawa
 
OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...
OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...
OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...VirtualTech Japan Inc.
 
Yocto bspを作ってみた
Yocto bspを作ってみたYocto bspを作ってみた
Yocto bspを作ってみたwata2ki
 
OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27Kentaro Ebisawa
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPThomas Graf
 
Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編Masahito Zembutsu
 
ML2/OVN アーキテクチャ概観
ML2/OVN アーキテクチャ概観ML2/OVN アーキテクチャ概観
ML2/OVN アーキテクチャ概観Yamato Tanaka
 

La actualidad más candente (20)

ELFの動的リンク
ELFの動的リンクELFの動的リンク
ELFの動的リンク
 
Wireshark だけに頼らない! パケット解析ツールの紹介
Wireshark だけに頼らない! パケット解析ツールの紹介Wireshark だけに頼らない! パケット解析ツールの紹介
Wireshark だけに頼らない! パケット解析ツールの紹介
 
シェル芸初心者によるシェル芸入門
シェル芸初心者によるシェル芸入門シェル芸初心者によるシェル芸入門
シェル芸初心者によるシェル芸入門
 
ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)
ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)
ストリーム処理におけるApache Avroの活用について(NTTデータ テクノロジーカンファレンス 2019 講演資料、2019/09/05)
 
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/FallZabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
Zabbix最新情報 ~Zabbix 6.0に向けて~ @OSC2021 Online/Fall
 
std::pin の勘所
std::pin の勘所std::pin の勘所
std::pin の勘所
 
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
 
レシピの作り方入門
レシピの作り方入門レシピの作り方入門
レシピの作り方入門
 
CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...
CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...
CyberAgentのプライベートクラウド Cycloudの運用及びモニタリングについて #CODT2020 / Administration and M...
 
雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニング雑なMySQLパフォーマンスチューニング
雑なMySQLパフォーマンスチューニング
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方
 
OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...
OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...
OVS VXLAN Network Accelaration on OpenStack (VXLAN offload and DPDK) - OpenSt...
 
Yocto bspを作ってみた
Yocto bspを作ってみたYocto bspを作ってみた
Yocto bspを作ってみた
 
OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
 
LLVM最適化のこつ
LLVM最適化のこつLLVM最適化のこつ
LLVM最適化のこつ
 
Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編Dockerfile を書くためのベストプラクティス解説編
Dockerfile を書くためのベストプラクティス解説編
 
eBPFを用いたトレーシングについて
eBPFを用いたトレーシングについてeBPFを用いたトレーシングについて
eBPFを用いたトレーシングについて
 
私とOSSの25年
私とOSSの25年私とOSSの25年
私とOSSの25年
 
ML2/OVN アーキテクチャ概観
ML2/OVN アーキテクチャ概観ML2/OVN アーキテクチャ概観
ML2/OVN アーキテクチャ概観
 

Similar a Linuxカーネルを読んで改めて知るプロセスとスレッドの違い

The Ring programming language version 1.5.3 book - Part 97 of 184
The Ring programming language version 1.5.3 book - Part 97 of 184The Ring programming language version 1.5.3 book - Part 97 of 184
The Ring programming language version 1.5.3 book - Part 97 of 184Mahmoud Samir Fayed
 
Lab 2 Histrogram generation Author Naga Kandasamy .docx
 Lab 2 Histrogram generation   Author Naga Kandasamy  .docx Lab 2 Histrogram generation   Author Naga Kandasamy  .docx
Lab 2 Histrogram generation Author Naga Kandasamy .docxaryan532920
 
Unit 4
Unit 4Unit 4
Unit 4siddr
 
TensorFlow 2: New Era of Developing Deep Learning Models
TensorFlow 2: New Era of Developing Deep Learning ModelsTensorFlow 2: New Era of Developing Deep Learning Models
TensorFlow 2: New Era of Developing Deep Learning ModelsJeongkyu Shin
 
Argoによる機械学習実行基盤の構築・運用からみえてきたこと
Argoによる機械学習実行基盤の構築・運用からみえてきたことArgoによる機械学習実行基盤の構築・運用からみえてきたこと
Argoによる機械学習実行基盤の構築・運用からみえてきたことShinsaku Kono
 
LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityBrendan Gregg
 
Google Polymer in Action
Google Polymer in ActionGoogle Polymer in Action
Google Polymer in ActionJeongkyu Shin
 
ROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
ROS2勉強会@別府 第7章PythonクライアントライブラリrclpyROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
ROS2勉強会@別府 第7章PythonクライアントライブラリrclpyAtsuki Yokota
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersMarina Kolpakova
 
Crash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenCrash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenLex Yu
 
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовRust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовYandex
 
The Ring programming language version 1.2 book - Part 61 of 84
The Ring programming language version 1.2 book - Part 61 of 84The Ring programming language version 1.2 book - Part 61 of 84
The Ring programming language version 1.2 book - Part 61 of 84Mahmoud Samir Fayed
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp fullVõ Hòa
 
The Ring programming language version 1.3 book - Part 67 of 88
The Ring programming language version 1.3 book - Part 67 of 88The Ring programming language version 1.3 book - Part 67 of 88
The Ring programming language version 1.3 book - Part 67 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 87 of 196
The Ring programming language version 1.7 book - Part 87 of 196The Ring programming language version 1.7 book - Part 87 of 196
The Ring programming language version 1.7 book - Part 87 of 196Mahmoud Samir Fayed
 
Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3guesta3202
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisaujihisa
 
AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方
AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方
AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方Salesforce Developers Japan
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdfajay1317
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPAdam Englander
 

Similar a Linuxカーネルを読んで改めて知るプロセスとスレッドの違い (20)

The Ring programming language version 1.5.3 book - Part 97 of 184
The Ring programming language version 1.5.3 book - Part 97 of 184The Ring programming language version 1.5.3 book - Part 97 of 184
The Ring programming language version 1.5.3 book - Part 97 of 184
 
Lab 2 Histrogram generation Author Naga Kandasamy .docx
 Lab 2 Histrogram generation   Author Naga Kandasamy  .docx Lab 2 Histrogram generation   Author Naga Kandasamy  .docx
Lab 2 Histrogram generation Author Naga Kandasamy .docx
 
Unit 4
Unit 4Unit 4
Unit 4
 
TensorFlow 2: New Era of Developing Deep Learning Models
TensorFlow 2: New Era of Developing Deep Learning ModelsTensorFlow 2: New Era of Developing Deep Learning Models
TensorFlow 2: New Era of Developing Deep Learning Models
 
Argoによる機械学習実行基盤の構築・運用からみえてきたこと
Argoによる機械学習実行基盤の構築・運用からみえてきたことArgoによる機械学習実行基盤の構築・運用からみえてきたこと
Argoによる機械学習実行基盤の構築・運用からみえてきたこと
 
LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF Observability
 
Google Polymer in Action
Google Polymer in ActionGoogle Polymer in Action
Google Polymer in Action
 
ROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
ROS2勉強会@別府 第7章PythonクライアントライブラリrclpyROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
ROS2勉強会@別府 第7章Pythonクライアントライブラリrclpy
 
Code GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limitersCode GPU with CUDA - Identifying performance limiters
Code GPU with CUDA - Identifying performance limiters
 
Crash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenCrash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_Tizen
 
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовRust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
 
The Ring programming language version 1.2 book - Part 61 of 84
The Ring programming language version 1.2 book - Part 61 of 84The Ring programming language version 1.2 book - Part 61 of 84
The Ring programming language version 1.2 book - Part 61 of 84
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
The Ring programming language version 1.3 book - Part 67 of 88
The Ring programming language version 1.3 book - Part 67 of 88The Ring programming language version 1.3 book - Part 67 of 88
The Ring programming language version 1.3 book - Part 67 of 88
 
The Ring programming language version 1.7 book - Part 87 of 196
The Ring programming language version 1.7 book - Part 87 of 196The Ring programming language version 1.7 book - Part 87 of 196
The Ring programming language version 1.7 book - Part 87 of 196
 
Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3Erlang Introduction Bcberlin3
Erlang Introduction Bcberlin3
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 
AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方
AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方
AIアプリはこう作る!-独自の識別モデル作成も簡単 Einstein Platform Services の使い方
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHPphp[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
 

Más de Retrieva inc.

コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜Retrieva inc.
 
音声認識入門(前編)
音声認識入門(前編)音声認識入門(前編)
音声認識入門(前編)Retrieva inc.
 
自然言語処理シリーズ9 構文解析 3.6-3.8節
自然言語処理シリーズ9 構文解析 3.6-3.8節自然言語処理シリーズ9 構文解析 3.6-3.8節
自然言語処理シリーズ9 構文解析 3.6-3.8節Retrieva inc.
 
IP電話交換機ソフト Asterisk について
IP電話交換機ソフト Asterisk についてIP電話交換機ソフト Asterisk について
IP電話交換機ソフト Asterisk についてRetrieva inc.
 
論理的思考で読解力を培う
論理的思考で読解力を培う論理的思考で読解力を培う
論理的思考で読解力を培うRetrieva inc.
 
キートップのノベルティを作ってみた話
キートップのノベルティを作ってみた話キートップのノベルティを作ってみた話
キートップのノベルティを作ってみた話Retrieva inc.
 
自然言語処理勉強会11章 情報抽出と知識獲得
自然言語処理勉強会11章 情報抽出と知識獲得自然言語処理勉強会11章 情報抽出と知識獲得
自然言語処理勉強会11章 情報抽出と知識獲得Retrieva inc.
 
キートップのノベルティを作った話
キートップのノベルティを作った話キートップのノベルティを作った話
キートップのノベルティを作った話Retrieva inc.
 
放送大学テキスト「自然言語処理」 6章 意味の解析(1)
放送大学テキスト「自然言語処理」 6章 意味の解析(1)放送大学テキスト「自然言語処理」 6章 意味の解析(1)
放送大学テキスト「自然言語処理」 6章 意味の解析(1)Retrieva inc.
 
キーボード自作のススメ
キーボード自作のススメキーボード自作のススメ
キーボード自作のススメRetrieva inc.
 
レトリバのキートップ説明書
レトリバのキートップ説明書レトリバのキートップ説明書
レトリバのキートップ説明書Retrieva inc.
 
ブースティング入門
ブースティング入門ブースティング入門
ブースティング入門Retrieva inc.
 
情報検索の基礎
情報検索の基礎情報検索の基礎
情報検索の基礎Retrieva inc.
 
Chainer の Trainer 解説と NStepLSTM について
Chainer の Trainer 解説と NStepLSTM についてChainer の Trainer 解説と NStepLSTM について
Chainer の Trainer 解説と NStepLSTM についてRetrieva inc.
 
ChainerでDeep Learningを試すために必要なこと
ChainerでDeep Learningを試すために必要なことChainerでDeep Learningを試すために必要なこと
ChainerでDeep Learningを試すために必要なことRetrieva inc.
 
20170221 cnet live講演資料
20170221 cnet live講演資料20170221 cnet live講演資料
20170221 cnet live講演資料Retrieva inc.
 
Making Google Cardboard and Laser Cutter
Making Google Cardboard and Laser CutterMaking Google Cardboard and Laser Cutter
Making Google Cardboard and Laser CutterRetrieva inc.
 
Chainerで学ぶdeep learning
Chainerで学ぶdeep learningChainerで学ぶdeep learning
Chainerで学ぶdeep learningRetrieva inc.
 

Más de Retrieva inc. (18)

コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
 
音声認識入門(前編)
音声認識入門(前編)音声認識入門(前編)
音声認識入門(前編)
 
自然言語処理シリーズ9 構文解析 3.6-3.8節
自然言語処理シリーズ9 構文解析 3.6-3.8節自然言語処理シリーズ9 構文解析 3.6-3.8節
自然言語処理シリーズ9 構文解析 3.6-3.8節
 
IP電話交換機ソフト Asterisk について
IP電話交換機ソフト Asterisk についてIP電話交換機ソフト Asterisk について
IP電話交換機ソフト Asterisk について
 
論理的思考で読解力を培う
論理的思考で読解力を培う論理的思考で読解力を培う
論理的思考で読解力を培う
 
キートップのノベルティを作ってみた話
キートップのノベルティを作ってみた話キートップのノベルティを作ってみた話
キートップのノベルティを作ってみた話
 
自然言語処理勉強会11章 情報抽出と知識獲得
自然言語処理勉強会11章 情報抽出と知識獲得自然言語処理勉強会11章 情報抽出と知識獲得
自然言語処理勉強会11章 情報抽出と知識獲得
 
キートップのノベルティを作った話
キートップのノベルティを作った話キートップのノベルティを作った話
キートップのノベルティを作った話
 
放送大学テキスト「自然言語処理」 6章 意味の解析(1)
放送大学テキスト「自然言語処理」 6章 意味の解析(1)放送大学テキスト「自然言語処理」 6章 意味の解析(1)
放送大学テキスト「自然言語処理」 6章 意味の解析(1)
 
キーボード自作のススメ
キーボード自作のススメキーボード自作のススメ
キーボード自作のススメ
 
レトリバのキートップ説明書
レトリバのキートップ説明書レトリバのキートップ説明書
レトリバのキートップ説明書
 
ブースティング入門
ブースティング入門ブースティング入門
ブースティング入門
 
情報検索の基礎
情報検索の基礎情報検索の基礎
情報検索の基礎
 
Chainer の Trainer 解説と NStepLSTM について
Chainer の Trainer 解説と NStepLSTM についてChainer の Trainer 解説と NStepLSTM について
Chainer の Trainer 解説と NStepLSTM について
 
ChainerでDeep Learningを試すために必要なこと
ChainerでDeep Learningを試すために必要なことChainerでDeep Learningを試すために必要なこと
ChainerでDeep Learningを試すために必要なこと
 
20170221 cnet live講演資料
20170221 cnet live講演資料20170221 cnet live講演資料
20170221 cnet live講演資料
 
Making Google Cardboard and Laser Cutter
Making Google Cardboard and Laser CutterMaking Google Cardboard and Laser Cutter
Making Google Cardboard and Laser Cutter
 
Chainerで学ぶdeep learning
Chainerで学ぶdeep learningChainerで学ぶdeep learning
Chainerで学ぶdeep learning
 

Último

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Último (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Linuxカーネルを読んで改めて知るプロセスとスレッドの違い

  • 1. 8 A 1. 0 1., 2 1 2 1
  • 2. / 2/ , 5 44 201 8 /8/ /. • ed 8 • R@ I • a • cg A @
  • 3. • c c gd t l • c efho t Rs • t c gd = I • t i a • 81 . , 8 3 81 . . ., 82 t • c xu t i a Rs A • efho n • i a c rv .8 2.: , 33 2018 . . :.
  • 4. • 02 8 I RA L R A cd • I • a e • I 0 2 11 0. 4 4 ,
  • 5. • .: C I c il • A 8: C 4 2 5A : C • ,/1 .: 2 G il • A 8 C 8 A 7 2 : 4 A 2 5 • aI Rnv otRghm I I fsL U • I I Rbd r U • .: C Rpue UN 0 : 2 4 :8 A A 5
  • 6. • • 0268A L • • • • R a • I • 0 2 11 0. ,
  • 7. ( 0 0 - 7. ) 2 0 0 0 • 18 • A I • A I • 18 • 18 ,18 R #include <stdio.h> #include <unistd.h> int main() { pid_t pid = fork(); // forkA if (pid == -1) { printf("Fork failed¥n"); // } else if (pid == 0) { printf("Child process, pid: %d¥n", getpid()); // } else { printf("Parent process, pid: %d¥n", getpid()); } } $ gcc fork_sample.c && ./a.out Parent process, pid: 72390 Child process, pid: 72391
  • 8. 0 A: 2 . 4# A:8 A A 5# • , 8: #4 A 2 5 : (# A 7 A #4 / ) • 17 A RL15 17 A I #ifdef __ARCH_WANT_SYS_FORK SYSCALL_DEFINE0(fork) { #ifdef CONFIG_MMU return _do_fork(SIGCHLD, 0, 0, NULL, NULL, 0); #else /* can not support in nommu mode */ return -EINVAL; #endif } #endif
  • 9. • • 02 8A L • • • • R a • I • 9 0 2 11 0. ,
  • 10. 8 8 << 8 8 8 • .-0 8 GT • I G.-0 O S • NP • AC1 8 • , .1 • ,.1 ,2 < GLR
  • 11. ). 1. ( , 1 0 8 .8. . • 0 . , . . I • 0 . 2 1 I R A #include <stdio.h> #include <pthread.h> void* print_doubled(void *x) { int *ix = (int *)x; printf("%d¥n", *ix * 2); } int main() { pthread_t th; int x = 100; int ret = pthread_create( &th, NULL, print_doubled, (void *)&x); if (ret != 0) { printf("thread execution failed"); return 255; } pthread_join(th, NULL); return 0; } $ gcc -lpthread pthread_sample.c $ ./a.out 200
  • 12. ( ( # 2 : 2 / 70 66 : :2 2: 21 • 7 6 :2/1.0:2/ 2 0 , # • R • 72 :2/1 I 1 • / : :2/1. :2/1./ : • /: .:8 72 I A LR • /: /: .:8 72 R int __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
  • 13. ( ( 2 , ) (33 201 8 8 . • 1 ,. 8 , 2 , 0 A • , 1 ,. 1 ,. int __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg) { const struct pthread_attr *iattr = (struct pthread_attr *) attr; struct pthread *pd = NULL; int err = ALLOCATE_STACK(iattr, &pd); /* */ pd->start_routine = start_routine; pd->arg = arg; /* */ *newthread = (pthread_t) pd; /* */ int retval = create_thread(pd, iattr, ...); return retval; }
  • 14. 8 8 / # A 8A8 87# ( • A A78 A C E A A CE 8 8 8 7# 0() • ,.4,021 A A4 8 R HN O IL static int create_thread (struct pthread *pd, const struct pthread_attr *attr, bool *stopped_start, STACK_VARIABLES_PARMS, bool *thread_ran) { /* */ const int clone_flags = (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SYSVSEM | CLONE_SIGHAND | CLONE_THREAD | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | 0); /* */ ARCH_CLONE(&start_thread, STACK_VARIABLES_PARMS, clone_flags, pd, &pd->tid, tp, &pd->tid); /* */ return 0; }
  • 15. 0 A: 2 . 4# A:8 A A 5# ) • , 8: #4 A 2 5 : (# A 7 A #4 / • 14 15 17 A L I SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, int __user *, parent_tidptr, int __user *, child_tidptr, unsigned long, tls) { return _do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr, tls); }
  • 16. ) ) ( I GEA H: 0C EA GF E F EH • N LM _ O DC > : FO • TV 60. 1 • RS 1 , 82 1 , -6 1 , -01,6 1 , ,
  • 17. M I : /D IH H • IIFH D LAC EH D AF IC 0 C:D F: H C:D ED IC • 0 2, 81 • Rx mtedV mted Sop u • 0 2, - • Rx mtedV mtedP S rcdhn v T • 0 2, -/0, • Rx mtedV mted ri_da m hNlr v T • 0 2, 7. , • mted Rx mtedV Sdsgj rNm O
  • 18. # . / , 1 77 45 2 /* * cloning flags: */ #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ #define CLONE_VM 0x00000100 /* set if VM shared between processes */ #define CLONE_FS 0x00000200 /* set if fs info shared between processes */ #define CLONE_FILES 0x00000400 /* set if open files shared between processes */ #define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ /* */ #define CLONE_NEWPID 0x20000000 /* New pid namespace */ #define CLONE_NEWNET 0x40000000 /* New network namespace */ #define CLONE_IO 0x80000000 /* Clone io context */ • 5 4 5 0 1:8 : /72 7 A 07:0 17 2 / 7 A 15 2 5 • L 0 • I 0 4 /7
  • 19. 8 , ) ( 8 12 9 8 9 8 . • _ Ied 0 8 R A • Ied R A • I R . 0 8 • ed fcI ag
  • 20. • • 1 R L • I R • • IA • 8 , 2 , 1 00 2 . 2, ,2 ,
  • 21. # . A 7 / , 1 75 A 2 • AA 57A 0 1 : A / 2 7 0 0 8 4 8 1 # • R I L long _do_fork(unsigned long clone_flags, unsigned long stack_start, unsigned long stack_size, int __user *parent_tidptr, int __user *child_tidptr, unsigned long tls)
  • 22. # /5A 85 1 ,:: 8 7A 5 5 54 • 7AA 8A7 2 A 1:4 :8 2: 2 8 : 45 :8 754 7 . • A1 90 A A aI b • _ R L struct task_struct { struct thread_info thread_info; volatile long state; void *stack; struct mm_struct *mm; struct mm_struct *active_mm; pid_t pid; pid_t tgid; /* Filesystem information */ struct fs_struct *fs; /* Open file information */ struct files_struct *files; /* c */ }
  • 23. 2 , ) ( 201 . • I A I • ,3 , 3 I R A 8 long _do_fork(unsigned long clone_flags, unsigned long stack_start, unsigned long stack_size, int __user *parent_tidptr, int __user *child_tidptr, unsigned long tls) { struct task_struct *p; /* */ p = copy_process( clone_flags, stack_start, stack_size, child_tidptr, NULL, trace, tls, NUMA_NO_NODE); /* */ struct pid *pid = get_task_pid(p, PIDTYPE_PID); long nr = pid_vnr(pid); wake_up_new_task(p); /* */ return nr; }
  • 24. 0 A: 2 . 4# A:8 A A 5# ( • , 8: #4 A 2 5 : (# A 7 A #4 / ) • 5 1 2 1 A 4 • m Rb hf o I di a kr • 4 1 • p Rh_ m e • nl e g c L static struct task_struct *copy_process( unsigned long clone_flags, unsigned long stack_start, unsigned long stack_size, int __user *child_tidptr, ...) { struct task_struct *p; int retval; /* s */ p = dup_task_struct(current, node); /* s */ retval = copy_fs(clone_flags, p); if (retval) goto bad_fork_cleanup_files; retval = copy_mm(clone_flags, p); if (retval) goto bad_fork_cleanup_signal; /* s */ return p; }
  • 25. N # 4 I 8 . : I • II I :EC IE 8 L E A E A : / • :E M7CCt mnpus diP U R • : I vx, 5 I8 A7 I :I ah e lbr • e gh ,/21 7 0 oc y V_ diPV_ Ok rfe ,/21 7 0 oc y V_ diP static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) { struct mm_struct *mm, *oldmm; /* */ oldmm = current->mm; /* */ if (clone_flags & CLONE_VM) { mmget(oldmm); mm = oldmm; goto good_mm; } mm = dup_mm(tsk); good_mm: tsk->mm = mm; tsk->active_mm = mm; return 0; /* */ }
  • 26. 0 22 0. 6 6 , • A 61 6 8 a • _ 2 R I A c • d A
  • 27. • • 02 8A R • • R • L I • 0 7 2 11 0. 7 ,
  • 28. • l Sd O l • Sd O ah • = i c I Ie n R ad A • ISd O g 8 . 1. , 22 1 0 . . .
  • 29. ( ( ) ( I , 28 8 4 0 # / 9: 8 8 87# • : A . 9 : 5# 4 7 5 5 )# 8 8 :87 8# 1 ,( • :3 abed g RL :3 _ c g R static __always_inline struct rq * context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next, /* h */) { struct mm_struct *mm, *oldmm; mm = next->mm; old_mm = prev->active_mm; /* h */ if (!mm) { /* h */ } else switch_mm_irqs_off(oldmm, mm, next); /* h */ switch_to(prev, next, prev); barrier(); return finish_task_switch(prev); }
  • 30. ) ( ) # /4 74A0 :2 ,88 7 6 4 4 A43 # • 6 7 6 1 2 A083 87: 18 1 A 0 26 81 2 . • R I L void switch_mm_irqs_off(struct mm_struct * prev, struct mm_struct *next, struct task_struct *tsk) { struct mm_struct *real_prev = this_cpu_read(cpu_tlbstate.loaded_mm); if (real_prev == next) { /* */ return; } else { /* */ } /* */ }
  • 31. 8 . 1. 3, 22 1 0 . . . • i a d R c • a ge l nA I Sc O h
  • 32. • a • 02 8 L R • I • R I • R c • • A 30 2 11 30. 3 3 ,
  • 33. 0 0 ) . ( 23 0 0 0 • go 18 h A I nad . 8 0 h A I R , . v I , 8,18 R • nad x . 8 0fk l_A go s R • nad i ltr s R c a go L • 18 u Ae I L i
  • 34. /4A 74 0 - 2 ,:: 7 A 4 4 43 • da.7 g l • .7 R bmLjihc • AA 71 2 34 4: 4 9 8 :7 :71 0 : :7 24 0 0 4 4 A 7 34 A : • .7 • AA 797 17A 7 4 2 :7 94 4: 4 • L e kI • AA 3 0A4 0 4 8 0 0
  • 35. 1. 0 1., 2 1 2 1