diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/note.md" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/note.md"
index 1b07100bc26422396ee26f23d19402897cd76b7e..92fa3c390103bade07fb18c4cc21ddd3f21687a5 100644
--- "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/note.md"
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/note.md"
@@ -18,4 +18,74 @@ cat /proc/sched_debug
cat /proc/schedstat
```
![image](./record/pic/3-4.png)
-![image](./record/pic/3-5.png)
\ No newline at end of file
+![image](./record/pic/3-5.png)
+#### 3-6 ps –aux 查看进程状态
+```bash
+ps -aux
+```
+![image](./record/pic/3-6.png)
+* R:TASK_RUNNING 可执行状态,包括就绪和正在 CPU 上执行
+* S:TASK_INTERRUPTIBLE 可中断的睡眠状态,也是操作系统课程中所谓的阻塞状态
+* D:TASK_UNINTERRUPTIBLE 不可中断的睡眠状态
+* T:TASK_STOPPED 或 TASK_TRACED 暂停状态或跟踪状态
+* Z:TASK_DEAD(-EXIT_ZOMBIE) 退出状态,且成为僵尸进程
+* X:TASK_DEAD(-EXIT_DEAD) 退出状态,且进程即将被销毁
+#### 3-7&3-8 就绪与阻塞
+3-7 HelloWorld-loop-getchar 的运行输出
+![image](./record/pic/3-7.png)
+3-8 用 ps 观察 HelloWorld-loop-getchar 进程调度状态变化
+```bash
+ps aux|grep HelloWorld-loop-getchar
+```
+![image](./record/pic/3-8.png)
+
+#### 3-9&3-10 进程的调度统计
+```bash
+cat /proc/15366/status
+```
+![image](./record/pic/3-9.png)
+进程主动切换的次数8,进程主动切换的次数213
+
+```bash
+cat /proc/15363/stat
+```
+![image](./record/pic/3-10.png)
+
+#### 3-11&3-12&3-13&3-14普通进程的 CFS 调度
+* nice 命令可以用-xx 给出调整的数值(降低优先级 xx),也可以用“-n xx”方式直接设定 NICE 值(-
+20~19)
+* taskset -c 0 在命令前加上这条语句可以绑定进程运行在制定CPU
+3-11 执行 Run-NICE.sh 脚本并用 ps –a 查看
+![image](./record/pic/3-11.png)
+
+3-12 用 top 观察优先权不同的两个进程
+![image](./record/pic/3-12.png)
+16460 号进程占用了 CPU 的 90.4%的时间,16461 号进程仅占用了 CPU 的 9.6%的时间。
+
+3-13 /proc/PID/sched
+![image](./record/pic/3-13_1.png)
+![image](./record/pic/3-13_2.png)
+3-14 /proc/PID/schedstat
+![image](./record/pic/3-14.png)
+
+#### 3-15&3-16创建实时进程
+* 以 root 身份运行 RT-process-demo 进程,如果以普通用户运行 RT-process-demo 则会报告不允许创建实时进程。
+
+3-15 用 ps –al 观察 RT-process-demo 的四个观测点
+![image](./record/pic/3-15a.png)
+![image](./record/pic/3-15b.png)
+![image](./record/pic/3-15c.png)
+![image](./record/pic/3-15d.png)
+3-16 用/proc/PID/sched 观察 RT-process-demo 的四个观测点
+![image](./record/pic/3-16a.png)
+
+![image](./record/pic/3-16b.png)
+
+![image](./record/pic/3-16c.png)
+
+![image](./record/pic/3-16d.png)
+
+```bash
+sudo taskset -c 0 ./RR-FIFO.sh
+```
+经过多次测试发现实验结果无法在ubuntu18.04 多核处理(非虚拟机)器下复现
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop"
new file mode 100644
index 0000000000000000000000000000000000000000..d63c0d4931a6f826e18440dda6066d375daecb57
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop-getchar" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop-getchar"
new file mode 100644
index 0000000000000000000000000000000000000000..d6492af2ea8d73bb538d0a5b2a1f7a355fe1ea07
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop-getchar" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop-getchar.c" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop-getchar.c"
new file mode 100644
index 0000000000000000000000000000000000000000..cbb92c7d56da065706c9f6a7059c03bd74f5f0f8
--- /dev/null
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop-getchar.c"
@@ -0,0 +1,16 @@
+#include
+int main()
+{
+ long i,j,temp;
+ printf("HelloWorld!\n");
+ while(1)
+ {
+ for (i=0;i<1024*1024*1024;i++)
+ {
+ temp+=1;
+ }
+ printf("one iteration!\n");
+ getchar();
+ }
+ return 0;
+}
\ No newline at end of file
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop.c" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop.c"
new file mode 100644
index 0000000000000000000000000000000000000000..4c4fc0308334f113cc19f2a0291ab407b3d218ef
--- /dev/null
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/HelloWorld-loop.c"
@@ -0,0 +1,15 @@
+#include
+int main()
+{
+ long i,j,temp;
+ printf("HelloWorld!\n");
+ while(1)
+ {
+ for (i=0;i<1024*1024*1024;i++)
+ {
+ temp+=1;
+ }
+ printf("one iteration!\n");
+ }
+ return 0;
+}
\ No newline at end of file
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO-sched" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO-sched"
new file mode 100644
index 0000000000000000000000000000000000000000..6fdedd4be7430e2556e8adf5fe96dbe360ba8685
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO-sched" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO-sched.c" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO-sched.c"
new file mode 100644
index 0000000000000000000000000000000000000000..93a84a5adb0dbf4126b5c8d8846c0bad7834a6d4
--- /dev/null
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO-sched.c"
@@ -0,0 +1,36 @@
+#include
+#include
+#include
+#include
+#include
+
+int main(int argc,char ** argv)
+{
+ long i,j,temp;
+ char cmd_str[100];
+ int rc,current_scheduler_policy;
+ struct sched_param my_params;
+ //将要设置的调度参数
+ if(argc!=3)
+ {
+ printf("usage:RR-FIFO-sched sched_class priority \nsched_class: 0 for CFS; 1 forFIFO; 2 for RR\n");
+ exit(1);
+ }
+ my_params.sched_priority=atoi(argv[2]);
+ rc=sched_setscheduler(0,atoi(argv[1]),&my_params);
+ if(rc<0)
+ {
+ perror("sched_setscheduler error\n");
+ exit(0);
+ }
+ current_scheduler_policy=sched_getscheduler(0);
+ printf("the PID:%d current scheduler = %d \n", getpid(),current_scheduler_policy);
+ for(i=0;i<1024*1024*1024;i++)
+ for(j=0;j<10;j++)
+ temp++;
+ sprintf(cmd_str,"cat /proc/%d/sched > ./sched-%d ; date >> ./sched-%d", getpid(),
+ getpid(), getpid());
+ system(cmd_str);
+ //记录各个进程的/proc/PID/sched 以及时间信息
+ return 0;
+}
\ No newline at end of file
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO.sh" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO.sh"
new file mode 100644
index 0000000000000000000000000000000000000000..123b27406798feb4d90f16097babe0117208ab0e
--- /dev/null
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RR-FIFO.sh"
@@ -0,0 +1,4 @@
+./RR-FIFO-sched 2 90&
+./RR-FIFO-sched 2 90&
+sleep 5s
+./RR-FIFO-sched 1 95&
\ No newline at end of file
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RT-process-demo" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RT-process-demo"
new file mode 100644
index 0000000000000000000000000000000000000000..44794fddd433d5cb5684c9e28ba0ebce3352af30
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RT-process-demo" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RT-process-demo.c" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RT-process-demo.c"
new file mode 100644
index 0000000000000000000000000000000000000000..50a4a135c908f5962940af46e3ec28ce8e376dcb
--- /dev/null
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/RT-process-demo.c"
@@ -0,0 +1,58 @@
+#include
+#include
+#include
+#include
+#include
+
+
+int main()
+{
+ int rc,current_scheduler_policy;
+ struct sched_param my_params;
+ //将要设置的调度参数
+ current_scheduler_policy=sched_getscheduler(0);
+ printf("SCHED_OTHER = %d SCHED_FIFO =%d SCHED_RR=%d \n", SCHED_OTHER, SCHED_FIFO,SCHED_RR);
+ printf("the current scheduler = %d \n", current_scheduler_policy);
+ printf("press any key to change the current scheduler and priority to SCHED_RR\n");
+ getchar();
+ //checkpoint 1
+ my_params.sched_priority=sched_get_priority_max(SCHED_RR); // 最高的 RR 实时优先级
+ rc=sched_setscheduler(0,SCHED_RR,&my_params);
+ //设置为 RR 实时进程
+ if(rc<0)
+ {
+ perror("sched_setscheduler to SCHED_RR error");
+ exit(0);
+ }
+ current_scheduler_policy=sched_getscheduler(0);
+ printf("the current scheduler = %d \n", current_scheduler_policy);
+ printf("press any key to change the current scheduler and priority to SCHED_FIFO\n");
+ getchar();
+ //checkpoint 2
+ my_params.sched_priority=sched_get_priority_min(SCHED_FIFO); // 最低 FIFO 实时优先级
+ rc=sched_setscheduler(0,SCHED_FIFO,&my_params);
+ //设置为 FIFO 实时进程
+ if(rc<0)
+ {
+ perror("sched_setscheduler to SCHED_FIFO error");
+ exit(0);
+ }
+ current_scheduler_policy=sched_getscheduler(0);
+ printf("the current scheduler = %d \n", current_scheduler_policy);
+ printf("press any key to ange the current scheduler and priority to SCHED_OTHER(CFS)\n");
+ getchar();
+ //checkpoint 3
+ rc=sched_setscheduler(0,SCHED_OTHER,&my_params);
+ //设置为普通进程 3
+ if(rc<0)
+ {
+ perror("sched_setscheduler to SCHED_OTHER error");
+ exit(0);
+ }
+ current_scheduler_policy=sched_getscheduler(0);
+ printf("the current scheduler = %d \n", current_scheduler_policy);
+ printf("press any key to exit\n");
+ getchar();
+ //checkpoint 4
+ return 0;
+}
\ No newline at end of file
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/Run-NICE.sh" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/Run-NICE.sh"
new file mode 100644
index 0000000000000000000000000000000000000000..43bfe982d50fa84dfd25b4863c12b0068f48b881
--- /dev/null
+++ "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/code/Run-NICE.sh"
@@ -0,0 +1,2 @@
+taskset -c 0 ./HelloWorld-loop &
+taskset -c 0 nice -10 ./HelloWorld-loop &
\ No newline at end of file
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-10.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-10.png"
new file mode 100644
index 0000000000000000000000000000000000000000..0f99d927da59d632bce4968ad3154189cfc2d890
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-10.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-11.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-11.png"
new file mode 100644
index 0000000000000000000000000000000000000000..568ff46414b0dd92c0cc74cab01c674bf5511dcd
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-11.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-12.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-12.png"
new file mode 100644
index 0000000000000000000000000000000000000000..cff392e0dea9881ba16ff509c680bf8847158575
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-12.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-13_1.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-13_1.png"
new file mode 100644
index 0000000000000000000000000000000000000000..d362c929ab728f04fd9de5a20764471cd116394f
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-13_1.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-13_2.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-13_2.png"
new file mode 100644
index 0000000000000000000000000000000000000000..96a4f88a37f1dd59b7b4fb64d4b5d2853946d625
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-13_2.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-14.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-14.png"
new file mode 100644
index 0000000000000000000000000000000000000000..5ba8522fbd7dffcce7c9210c680e85b2ee3f0dbd
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-14.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15a.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15a.png"
new file mode 100644
index 0000000000000000000000000000000000000000..dfcb10863eda35fd5cf84e582fcc49b6e95562a7
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15a.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15b.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15b.png"
new file mode 100644
index 0000000000000000000000000000000000000000..9e2a55d1d16554cfca9cb18b4ea3189f9bb1116b
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15b.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15c.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15c.png"
new file mode 100644
index 0000000000000000000000000000000000000000..e8e150837b1498853cf53771164d9cef9e031ae1
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15c.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15d.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15d.png"
new file mode 100644
index 0000000000000000000000000000000000000000..802736d792a328c849664d4dbf1cc53e9410144f
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-15d.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16a.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16a.png"
new file mode 100644
index 0000000000000000000000000000000000000000..5e0593b54112dcc6a13c82d4e49f4d023a9f301d
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16a.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16b.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16b.png"
new file mode 100644
index 0000000000000000000000000000000000000000..b38c0c6381f8d91e53a22fa03e8d59a785249e3d
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16b.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16c.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16c.png"
new file mode 100644
index 0000000000000000000000000000000000000000..38c564fbe04ac4776d63c059403da7993e78849f
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16c.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16d.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16d.png"
new file mode 100644
index 0000000000000000000000000000000000000000..5e0593b54112dcc6a13c82d4e49f4d023a9f301d
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-16d.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-6.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-6.png"
new file mode 100644
index 0000000000000000000000000000000000000000..9d586205743602f95ce9c4fa5f46ec3638a2d184
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-6.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-7.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-7.png"
new file mode 100644
index 0000000000000000000000000000000000000000..64f1a5d044c127518dfc5690b65f55800efe6c3c
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-7.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-8.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-8.png"
new file mode 100644
index 0000000000000000000000000000000000000000..1705078bce53f35d4cfccde17e2f4122067100d2
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-8.png" differ
diff --git "a/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-9.png" "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-9.png"
new file mode 100644
index 0000000000000000000000000000000000000000..a21be0079a939a781a83877b52bdabb99b0f82c7
Binary files /dev/null and "b/3.\350\277\233\347\250\213\350\260\203\345\272\246/record/pic/3-9.png" differ