Skip to content

Commit 2004c65

Browse files
committed
modify chapter7
1 parent 1e38e81 commit 2004c65

File tree

2 files changed

+61
-14
lines changed

2 files changed

+61
-14
lines changed

chapter7/part2.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ impl Processor {
154154
// 将自身的正在运行线程设置为刚刚获取到的线程
155155
inner.current = Some(thread);
156156
// 从正在运行的线程 idle 切换到刚刚获取到的线程
157-
println!("\n>>>> will switch_to thread {} in CPU.run()!", inner.current.as_mut().unwrap().0);
157+
println!("\n>>>> will switch_to thread {} in idle_main!", inner.current.as_mut().unwrap().0);
158158
inner.idle.switch_to(
159159
&mut *inner.current.as_mut().unwrap().1
160160
);
161161

162162
// 上个线程时间耗尽,切换回调度线程 idle
163-
println!("<<<< switch_back to idle in CPU.run()!");
163+
println!("<<<< switch_back to idle in idle_main!");
164164
// 此时 current 还保存着上个线程
165165
let (tid, thread) = inner.current.take().unwrap();
166166
// 通知线程池这个线程需要将资源交还出去
@@ -190,7 +190,7 @@ impl Processor {
190190
use crate::process::tick;
191191

192192
// 时钟中断
193-
fn super_timer(tf: &mut TrapFrame) {
193+
fn super_timer() {
194194
clock_set_next_event();
195195
tick();
196196
}

chapter7/part4.md

+58-11
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,84 @@ pub extern "C" fn rust_main() -> ! {
103103
>
104104
> >>>> will switch_to thread 0 in idie_main!
105105
> begin of thread 0
106-
> 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
106+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
107+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
108+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
109+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
110+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
111+
> 000000000000
107112
> <<<< switch_back to idle in idle_main!
108113
>
109114
> >>>> will switch_to thread 1 in idie_main!
110115
> begin of thread 1
111-
> 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
116+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
117+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
118+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
119+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
120+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
121+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
122+
> 11111111111111111111111
112123
> <<<< switch_back to idle in idle_main!
113124
>
114125
> >>>> will switch_to thread 2 in idie_main!
115126
> begin of thread 2
116-
> 222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
127+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
128+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
129+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
130+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
131+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
132+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
133+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
134+
> 22222222222222222222222222222222222222
117135
> <<<< switch_back to idle in idle_main!
118136
>
119137
> >>>> will switch_to thread 3 in idie_main!
120138
> begin of thread 3
121-
> 333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
139+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
140+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
141+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
142+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
143+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
144+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
145+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
146+
> 33333333333333333333
122147
> <<<< switch_back to idle in idle_main!
123148
>
124149
> >>>> will switch_to thread 4 in idie_main!
125150
> begin of thread 4
126-
> 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
151+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
152+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
153+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
154+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
155+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
156+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
157+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
158+
> 444444444444444444444444
127159
> <<<< switch_back to idle in idle_main!
128160
>
129161
> >>>> will switch_to thread 0 in idie_main!
130-
> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
162+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
163+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
164+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
165+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
166+
> 0000000000000000000000000000000000000000000000000000000000000000000000000
167+
> 0000000000000000000000000000000000000000000000000000000000
131168
> end of thread 0
132169
> thread 0 exited, exit code = 0
133170
>
134171
> <<<< switch_back to idle in idle_main!
135172
>
136173
> >>>> will switch_to thread 1 in idie_main!
137-
> 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
174+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
175+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
176+
> 111111111111111111111111111111111111111111111111
138177
> <<<< switch_back to idle in idle_main!
139178
>
140179
> >>>> will switch_to thread 2 in idie_main!
141-
> 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
180+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
181+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
182+
> 2222222222222222222222222222222222222222222222222222222222222222222222222
183+
> 22222222222222222222222222222222
142184
> end of thread 2
143185
> thread 2 exited, exit code = 0
144186
>
@@ -149,11 +191,14 @@ pub extern "C" fn rust_main() -> ! {
149191
> <<<< switch_back to idle in idle_main!
150192
>
151193
> >>>> will switch_to thread 4 in idie_main!
152-
> 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
194+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
195+
> 4444444444444444444444444444444444444444444444444444444444444444444444444
196+
> 44444444444444444444444444444444444444444444444444444444444444444444
153197
> <<<< switch_back to idle in idle_main!
154198
>
155199
> >>>> will switch_to thread 1 in idie_main!
156-
> 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
200+
> 1111111111111111111111111111111111111111111111111111111111111111111111111
201+
> 111111111111111111111111111111111111111111111111111111111111111111111111
157202
> end of thread 1
158203
> thread 1 exited, exit code = 0
159204
>
@@ -175,7 +220,9 @@ pub extern "C" fn rust_main() -> ! {
175220
> <<<< switch_back to idle in idle_main!
176221
>
177222
> >>>> will switch_to thread 3 in idie_main!
178-
> 33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
223+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
224+
> 3333333333333333333333333333333333333333333333333333333333333333333333333
225+
> 333333333333333333333333333
179226
> end of thread 3
180227
> thread 3 exited, exit code = 0
181228
>

0 commit comments

Comments
 (0)