(context_ptr: *mut Context, handle: u64)
| 910 | } |
| 911 | |
| 912 | fn sys_close(context_ptr: *mut Context, handle: u64) { |
| 913 | // Extract the current thread |
| 914 | if let Some(mut thread) = process::take_current_thread() { |
| 915 | thread.set_context(context_ptr); |
| 916 | |
| 917 | // Take the Rendezvous from the thread |
| 918 | if let Some(rdv) = thread.take_rendezvous(handle) { |
| 919 | if Arc::strong_count(&rdv) == 2 { |
| 920 | // Only this handle (rdv) and one other |
| 921 | // All other handles have been dropped |
| 922 | let option_thread = rdv.write().close(); |
| 923 | if let Some(waiting_thread) = option_thread { |
| 924 | // A thread was waiting -> Switch to it |
| 925 | process::schedule_thread(thread); |
| 926 | process::schedule_thread(waiting_thread); |
| 927 | |
| 928 | drop(rdv); // Not returning from launch_thread |
| 929 | let new_context_addr = process::schedule_next(context_ptr as usize); |
| 930 | interrupts::launch_thread(new_context_addr); |
| 931 | } |
| 932 | } |
| 933 | // Drop rendezvous |
| 934 | } |
| 935 | process::set_current_thread(thread); |
| 936 | } |
| 937 | } |
| 938 | |
| 939 | fn sys_await_interrupt(context_ptr: *mut Context, _interrupt_number: u64) { |
| 940 | // Extract the current thread |
no test coverage detected