-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pedro Falcato <[email protected]>
- Loading branch information
Showing
11 changed files
with
236 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2016 - 2023 Pedro Falcato | ||
* This file is part of Onyx, and is released under the terms of the MIT License | ||
* check LICENSE at the root directory for more information | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
#ifndef _ONYX_PREEMPT_H | ||
#define _ONYX_PREEMPT_H | ||
|
||
#include <onyx/compiler.h> | ||
#include <onyx/percpu.h> | ||
|
||
#include <platform/irq.h> | ||
|
||
void sched_enable_pulse(); | ||
|
||
void sched_handle_preempt(bool may_softirq); | ||
|
||
extern unsigned long preemption_counter; | ||
|
||
__always_inline bool sched_is_preemption_disabled() | ||
{ | ||
return get_per_cpu(preemption_counter) > 0; | ||
} | ||
|
||
__always_inline unsigned long sched_get_preempt_counter() | ||
{ | ||
return get_per_cpu(preemption_counter); | ||
} | ||
|
||
__always_inline void __sched_enable_preempt() | ||
{ | ||
dec_per_cpu(preemption_counter); | ||
} | ||
|
||
__always_inline void sched_enable_preempt_no_softirq() | ||
{ | ||
__sched_enable_preempt(); | ||
} | ||
|
||
__always_inline void sched_enable_preempt() | ||
{ | ||
__sched_enable_preempt(); | ||
unsigned long counter = get_per_cpu(preemption_counter); | ||
|
||
// If preemption is enabled, try to do various tasks | ||
// softirq, rescheduling, etc | ||
if (counter == 0 && !irq_is_disabled()) [[unlikely]] | ||
{ | ||
sched_handle_preempt(true); | ||
} | ||
} | ||
|
||
__always_inline void sched_disable_preempt() | ||
{ | ||
inc_per_cpu(preemption_counter); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.