Add the task, the thread and possibly its process, process group and session to the corresponding tables.
(task: &AxTaskRef)
| 357 | /// Add the task, the thread and possibly its process, process group and session |
| 358 | /// to the corresponding tables. |
| 359 | pub 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. |
| 390 | pub fn tasks() -> Vec<AxTaskRef> { |
no test coverage detected