SlideShare a Scribd company logo
1 of 35
Download to read offline
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

More Related Content

What's hot

PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)
PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)
PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)NTT DATA Technology & Innovation
 
本当は恐ろしい分散システムの話
本当は恐ろしい分散システムの話本当は恐ろしい分散システムの話
本当は恐ろしい分散システムの話Kumazaki Hiroki
 
JVMのGCアルゴリズムとチューニング
JVMのGCアルゴリズムとチューニングJVMのGCアルゴリズムとチューニング
JVMのGCアルゴリズムとチューニング佑哉 廣岡
 
What's new in Spring Batch 5
What's new in Spring Batch 5What's new in Spring Batch 5
What's new in Spring Batch 5ikeyat
 
Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装Ryuichi Sakamoto
 
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)NTT DATA Technology & Innovation
 
Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Akihiro Suda
 
君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?Teppei Sato
 
マイクロにしすぎた結果がこれだよ!
マイクロにしすぎた結果がこれだよ!マイクロにしすぎた結果がこれだよ!
マイクロにしすぎた結果がこれだよ!mosa siru
 
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)NTT DATA Technology & Innovation
 
WebAssemblyのWeb以外のことぜんぶ話す
WebAssemblyのWeb以外のことぜんぶ話すWebAssemblyのWeb以外のことぜんぶ話す
WebAssemblyのWeb以外のことぜんぶ話すTakaya Saeki
 
DockerとPodmanの比較
DockerとPodmanの比較DockerとPodmanの比較
DockerとPodmanの比較Akihiro Suda
 
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)NTT DATA Technology & Innovation
 
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)NTT DATA Technology & Innovation
 
Redmineとgitの 連携利用事例
Redmineとgitの 連携利用事例Redmineとgitの 連携利用事例
Redmineとgitの 連携利用事例Tomohisa Kusukawa
 
あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界Yoshinori Nakanishi
 
暗号技術の実装と数学
暗号技術の実装と数学暗号技術の実装と数学
暗号技術の実装と数学MITSUNARI Shigeo
 
メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?Takuya Ueda
 

What's hot (20)

PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)
PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)
PostgreSQLのロール管理とその注意点(Open Source Conference 2022 Online/Osaka 発表資料)
 
本当は恐ろしい分散システムの話
本当は恐ろしい分散システムの話本当は恐ろしい分散システムの話
本当は恐ろしい分散システムの話
 
JVMのGCアルゴリズムとチューニング
JVMのGCアルゴリズムとチューニングJVMのGCアルゴリズムとチューニング
JVMのGCアルゴリズムとチューニング
 
What's new in Spring Batch 5
What's new in Spring Batch 5What's new in Spring Batch 5
What's new in Spring Batch 5
 
Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装Slurmのジョブスケジューリングと実装
Slurmのジョブスケジューリングと実装
 
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
 
Dockerからcontainerdへの移行
Dockerからcontainerdへの移行Dockerからcontainerdへの移行
Dockerからcontainerdへの移行
 
君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?君はyarn.lockをコミットしているか?
君はyarn.lockをコミットしているか?
 
マイクロにしすぎた結果がこれだよ!
マイクロにしすぎた結果がこれだよ!マイクロにしすぎた結果がこれだよ!
マイクロにしすぎた結果がこれだよ!
 
HTTP/2 入門
HTTP/2 入門HTTP/2 入門
HTTP/2 入門
 
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
 
WebAssemblyのWeb以外のことぜんぶ話す
WebAssemblyのWeb以外のことぜんぶ話すWebAssemblyのWeb以外のことぜんぶ話す
WebAssemblyのWeb以外のことぜんぶ話す
 
DockerとPodmanの比較
DockerとPodmanの比較DockerとPodmanの比較
DockerとPodmanの比較
 
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
押さえておきたい、PostgreSQL 13 の新機能!! (PostgreSQL Conference Japan 2020講演資料)
 
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_bigmで全文検索するときに気を付けたい5つのポイント(第23回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
Redmineとgitの 連携利用事例
Redmineとgitの 連携利用事例Redmineとgitの 連携利用事例
Redmineとgitの 連携利用事例
 
あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界あなたの知らないPostgreSQL監視の世界
あなたの知らないPostgreSQL監視の世界
 
暗号技術の実装と数学
暗号技術の実装と数学暗号技術の実装と数学
暗号技術の実装と数学
 
メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?
 
ヤフー社内でやってるMySQLチューニングセミナー大公開
ヤフー社内でやってるMySQLチューニングセミナー大公開ヤフー社内でやってるMySQLチューニングセミナー大公開
ヤフー社内でやってるMySQLチューニングセミナー大公開
 

Similar to 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 to 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
 

More from 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.
 

More from 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
 

Recently uploaded

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 

Recently uploaded (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 

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