MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / sys_close

Function sys_close

kernel/src/syscalls.rs:912–937  ·  view source on GitHub ↗
(context_ptr: *mut Context, handle: u64)

Source from the content-addressed store, hash-verified

910}
911
912fn 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
939fn sys_await_interrupt(context_ptr: *mut Context, _interrupt_number: u64) {
940 // Extract the current thread

Callers 1

dispatch_syscallFunction · 0.85

Calls 9

take_current_threadFunction · 0.85
schedule_threadFunction · 0.85
schedule_nextFunction · 0.85
launch_threadFunction · 0.85
set_current_threadFunction · 0.85
set_contextMethod · 0.80
take_rendezvousMethod · 0.80
closeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected