@@ -4,8 +4,8 @@ use alloc::{
4
4
string:: { String , ToString } ,
5
5
vec:: Vec ,
6
6
} ;
7
- use arch:: debug:: DebugConsole ;
8
- use executor:: { current_task, task:: TaskType , yield_now, TASK_QUEUE } ;
7
+ use arch:: { debug:: DebugConsole , hart_id , shutdown } ;
8
+ use executor:: { current_task, release_task , task:: TaskType , tid2task , yield_now, TASK_MAP } ;
9
9
use frame_allocator:: get_free_pages;
10
10
use fs:: {
11
11
dentry:: { dentry_open, dentry_root, DentryNode } ,
@@ -56,9 +56,9 @@ fn clear() {
56
56
}
57
57
58
58
async fn kill_all_tasks ( ) {
59
- TASK_QUEUE
60
- . lock ( )
61
- . retain ( |x| x . task_type != TaskType :: MonolithicTask ) ;
59
+ TASK_MAP . lock ( ) . values ( ) . into_iter ( ) . for_each ( |task| {
60
+ task . upgrade ( ) . inspect ( |x| x . exit ( 100 ) ) ;
61
+ } ) ;
62
62
}
63
63
64
64
async fn run_libc_test ( ) -> bool {
@@ -129,13 +129,10 @@ async fn file_command(cmd: &str) {
129
129
args_extend. extend ( args. into_iter ( ) ) ;
130
130
// args.into_iter().for_each(|x| args_extend.push(x));
131
131
let task_id = add_user_task ( & filename, args_extend, Vec :: new ( ) ) . await ;
132
+ let task = tid2task ( task_id) . unwrap ( ) ;
132
133
loop {
133
- if TASK_QUEUE
134
- . lock ( )
135
- . iter ( )
136
- . find ( |x| x. task . get_task_id ( ) == task_id)
137
- . is_none ( )
138
- {
134
+ if task. exit_code ( ) . is_some ( ) {
135
+ release_task ( task_id) ;
139
136
break ;
140
137
}
141
138
yield_now ( ) . await ;
@@ -225,6 +222,7 @@ pub async fn initproc() {
225
222
// }
226
223
227
224
println ! ( "start kernel tasks" ) ;
225
+
228
226
// command("ls").await;
229
227
// command("entry-static.exe crypt").await;
230
228
// command("./runtest.exe -w entry-dynamic.exe dlopen").await;
@@ -283,10 +281,12 @@ pub async fn initproc() {
283
281
// command("busybox echo run libctest_testcode.sh").await;
284
282
// command("busybox sh libctest_testcode.sh").await;
285
283
284
+ // command("busybox sh ./run-static.sh").await;
285
+ // command("./runtest.exe -w entry-dynamic.exe pthread_robust_detach").await;
286
286
// command("busybox echo 123").await;
287
- command ( "qjs.static test.js" ) . await ;
287
+ // command("qjs.static test.js").await;
288
288
// command("qjs.static").await;
289
- command ( "busybox sh" ) . await ;
289
+ // command("busybox sh").await;
290
290
// command("busybox echo run lua_testcode.sh").await;
291
291
// command("busybox sh lua_testcode.sh").await;
292
292
@@ -306,8 +306,8 @@ pub async fn initproc() {
306
306
// command("busybox echo run lmbench_testcode.sh").await;
307
307
// command("busybox sh lmbench_testcode.sh").await;
308
308
309
- // command("busybox echo run unixbench_testcode.sh").await;
310
- // command("busybox sh unixbench_testcode.sh").await;
309
+ command ( "busybox echo run unixbench_testcode.sh" ) . await ;
310
+ command ( "busybox sh unixbench_testcode.sh" ) . await ;
311
311
312
312
// command("copy-file-range-test-1").await;
313
313
// command("copy-file-range-test-2").await;
@@ -380,4 +380,18 @@ pub async fn initproc() {
380
380
381
381
// switch_to_kernel_page_table();
382
382
println ! ( "!TEST FINISH!" ) ;
383
+
384
+ // Shutdown if there just have blankkernel task.
385
+ if TASK_MAP
386
+ . lock ( )
387
+ . values ( )
388
+ . find ( |x| {
389
+ x. upgrade ( )
390
+ . map ( |x| x. get_task_type ( ) != TaskType :: BlankKernel )
391
+ . unwrap_or ( false )
392
+ } )
393
+ . is_none ( )
394
+ {
395
+ shutdown ( ) ;
396
+ }
383
397
}
0 commit comments