MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / add_task_to_table

Function add_task_to_table

core/src/task.rs:359–387  ·  view source on GitHub ↗

Add the task, the thread and possibly its process, process group and session to the corresponding tables.

(task: &AxTaskRef)

Source from the content-addressed store, hash-verified

357/// Add the task, the thread and possibly its process, process group and session
358/// to the corresponding tables.
359pub fn add_task_to_table(task: &AxTaskRef) {
360 let tid = task.id().as_u64() as Pid;
361
362 let mut task_table = TASK_TABLE.write();
363 task_table.insert(tid, task);
364
365 let proc_data = &task.as_thread().proc_data;
366 let proc = &proc_data.proc;
367 let pid = proc.pid();
368 let mut proc_table = PROCESS_TABLE.write();
369 if proc_table.contains_key(&pid) {
370 return;
371 }
372 proc_table.insert(pid, proc_data);
373
374 let pg = proc.group();
375 let mut pg_table = PROCESS_GROUP_TABLE.write();
376 if pg_table.contains_key(&pg.pgid()) {
377 return;
378 }
379 pg_table.insert(pg.pgid(), &pg);
380
381 let session = pg.session();
382 let mut session_table = SESSION_TABLE.write();
383 if session_table.contains_key(&session.sid()) {
384 return;
385 }
386 session_table.insert(session.sid(), &session);
387}
388
389/// Lists all tasks.
390pub fn tasks() -> Vec<AxTaskRef> {

Callers 2

run_initprocFunction · 0.85
sys_cloneFunction · 0.85

Calls 3

insertMethod · 0.80
as_threadMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected