From ba39842cde8d33243188a2dc22baa8f1581b1c2d Mon Sep 17 00:00:00 2001 From: bernie Date: Tue, 19 Oct 2004 08:47:13 +0000 Subject: [PATCH] proc_rename(), proc_forbid(), proc_permit(): New functions. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@243 38d2e660-2303-0410-9eaa-f027e97ec537 --- kern/proc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/kern/proc.c b/kern/proc.c index 975278b4..4099313d 100755 --- a/kern/proc.c +++ b/kern/proc.c @@ -17,6 +17,9 @@ /*#* *#* $Log$ + *#* Revision 1.17 2004/10/19 08:47:13 bernie + *#* proc_rename(), proc_forbid(), proc_permit(): New functions. + *#* *#* Revision 1.16 2004/10/03 20:39:28 bernie *#* Import changes from sc/firmware. *#* @@ -242,6 +245,14 @@ struct Process *proc_new_with_name(UNUSED(const char*, name), void (*entry)(void return proc; } +/*! Rename a process */ +void proc_rename(struct Process *proc, const char *name) +{ +#if CONFIG_KERN_MONITOR + monitor_rename(proc, name); +#endif +} + /*! * System scheduler: pass CPU control to the next process in @@ -380,6 +391,41 @@ IPTR proc_current_user_data(void) return CurrentProcess->user_data; } + +#if CONFIG_KERN_PREEMPTIVE + +/*! + * Disable preemptive task switching. + * + * The scheduler maintains a per-process nesting counter. Task switching is + * effectively re-enabled only when the number of calls to proc_permit() + * matches the number of calls to proc_forbid(). + * + * Calling functions that could sleep while task switching is disabled + * is dangerous, although supported. Preemptive task switching is + * resumed while the process is sleeping and disabled again as soon as + * it wakes up again. + * + * \sa proc_permit() + */ +void proc_forbid(void) +{ + /* No need to protect against interrupts here. */ + ++CurrentProcess->forbid_cnt; +} + +/*! + * Re-enable preemptive task switching. + * + * \sa proc_forbid() + */ +void proc_permit(void) +{ + /* No need to protect against interrupts here. */ + --CurrentProcess->forbid_cnt; +} + + #if 0 /* Simple testcase for the scheduler */ #include -- 2.25.1