summaryrefslogtreecommitdiff
path: root/kc/core/cpu/cpu_task.S
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2022-02-18 17:23:04 +0000
committerAda Christine <adachristine18@gmail.com>2022-02-18 17:23:04 +0000
commit7ad9d2715a737b1a1b9dd7ff411ffa6d27fb549e (patch)
tree7c0c313352591d0d4cb68d579040655304e60459 /kc/core/cpu/cpu_task.S
parent606b7dc226cb51077c016a8ea5fa862ac6ce1db4 (diff)
do nothing if the origin and target threads are the same
Diffstat (limited to 'kc/core/cpu/cpu_task.S')
-rw-r--r--kc/core/cpu/cpu_task.S4
1 files changed, 4 insertions, 0 deletions
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