From 7ad9d2715a737b1a1b9dd7ff411ffa6d27fb549e Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Fri, 18 Feb 2022 17:23:04 +0000 Subject: do nothing if the origin and target threads are the same --- kc/core/cpu/cpu_task.S | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'kc') diff --git a/kc/core/cpu/cpu_task.S b/kc/core/cpu/cpu_task.S index 4f9fd7b..7216d0e 100644 --- a/kc/core/cpu/cpu_task.S +++ b/kc/core/cpu/cpu_task.S @@ -17,6 +17,9 @@ cpu_set_thread: * rsi: pointer to control block of the current thread * rdx: pointer to this cpu's task state segment esp0 field */ + // test for attempt to switch to same thread + cmp %rdi,%rsi + je .Lnothing // test for a NULL origin thread test %rsi,%rsi // skip saving the state for a NULL origin thread @@ -45,6 +48,7 @@ cpu_set_thread: pop %r13 pop %r12 pop %rbx +.Lnothing: // do nothing if the threads are the same ret // leave into the new task .size cpu_set_thread, . - cpu_set_thread -- cgit v1.3.1-1-g115d