Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Clear RUNNING flag during kernel context switch, when we're clear of …
Browse files Browse the repository at this point in the history
…the stack
  • Loading branch information
klange committed May 27, 2021
1 parent 9a44cd2 commit e55cb7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions kernel/arch/x86_64/irq.S
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ arch_save_context:
.global arch_restore_context
.type arch_restore_context, @function
arch_restore_context:
mov %gs:0x10,%rax
cmp %gs:0x0,%rax
je 1f
lock andl $0xFFFFfff7,0x14(%rax)
1:
movq 0(%rdi), %rsp
movq 8(%rdi), %rbp
movl 24(%rdi), %eax
Expand Down
5 changes: 1 addition & 4 deletions kernel/sys/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,8 @@ void switch_next(void) {

/* Mark the process as running and started. */
__sync_or_and_fetch(&this_core->current_process->flags, PROC_FLAG_STARTED);

if (this_core->previous_process != this_core->current_process)
__sync_and_and_fetch(&this_core->previous_process->flags, ~(PROC_FLAG_RUNNING));

/* Restore the execution context of this process's kernel thread. */
/* Jump to next */
arch_restore_context(&this_core->current_process->thread);
__builtin_unreachable();
}
Expand Down

0 comments on commit e55cb7e

Please sign in to comment.