--- Gnu-Mach/kern/syscall_subr.c 2020/09/02 04:36:57 1.1 +++ Gnu-Mach/kern/syscall_subr.c 2020/09/02 04:49:55 1.1.1.5 @@ -27,29 +27,26 @@ * the rights to redistribute these changes. */ -#include -#include - #include #include #include #include #include #include +#include +#include #include #include #include +#include #include #include #include -#include #include /* for splsched */ #if MACH_FIXPRI #include -#endif MACH_FIXPRI - - +#endif /* MACH_FIXPRI */ /* * swtch and swtch_pri both attempt to context switch (logic in @@ -64,34 +61,26 @@ * returned, the thread should make one more check on the * lock and then be a good citizen and really suspend. */ - -extern void thread_depress_priority(); -extern kern_return_t thread_depress_abort(); - -#ifdef CONTINUATIONS -void swtch_continue() +void swtch_continue(void) { - register processor_t myprocessor; + processor_t myprocessor; myprocessor = current_processor(); thread_syscall_return(myprocessor->runq.count > 0 || myprocessor->processor_set->runq.count > 0); /*NOTREACHED*/ } -#else /* not CONTINUATIONS */ -#define swtch_continue 0 -#endif /* not CONTINUATIONS */ -boolean_t swtch() +boolean_t swtch(void) { - register processor_t myprocessor; + processor_t myprocessor; #if NCPUS > 1 myprocessor = current_processor(); if (myprocessor->runq.count == 0 && myprocessor->processor_set->runq.count == 0) return(FALSE); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ counter(c_swtch_block++); thread_block(swtch_continue); @@ -100,11 +89,10 @@ boolean_t swtch() myprocessor->processor_set->runq.count > 0); } -#ifdef CONTINUATIONS -void swtch_pri_continue() +void swtch_pri_continue(void) { - register thread_t thread = current_thread(); - register processor_t myprocessor; + thread_t thread = current_thread(); + processor_t myprocessor; if (thread->depress_priority >= 0) (void) thread_depress_abort(thread); @@ -113,26 +101,18 @@ void swtch_pri_continue() myprocessor->processor_set->runq.count > 0); /*NOTREACHED*/ } -#else /* not CONTINUATIONS */ -#define swtch_pri_continue 0 -#endif /* not CONTINUATIONS */ -boolean_t swtch_pri(pri) - int pri; +boolean_t swtch_pri(int pri) { - register thread_t thread = current_thread(); - register processor_t myprocessor; - -#ifdef lint - pri++; -#endif lint + thread_t thread = current_thread(); + processor_t myprocessor; #if NCPUS > 1 myprocessor = current_processor(); if (myprocessor->runq.count == 0 && myprocessor->processor_set->runq.count == 0) return(FALSE); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ /* * XXX need to think about depression duration. @@ -150,24 +130,18 @@ boolean_t swtch_pri(pri) myprocessor->processor_set->runq.count > 0); } -extern int hz; - -#ifdef CONTINUATIONS -void thread_switch_continue() +void thread_switch_continue(void) { - register thread_t cur_thread = current_thread(); + thread_t cur_thread = current_thread(); /* - * Restore depressed priority + * Restore depressed priority */ if (cur_thread->depress_priority >= 0) (void) thread_depress_abort(cur_thread); thread_syscall_return(KERN_SUCCESS); /*NOTREACHED*/ } -#else /* not CONTINUATIONS */ -#define thread_switch_continue 0 -#endif /* not CONTINUATIONS */ /* * thread_switch: @@ -177,13 +151,13 @@ void thread_switch_continue() * Fixed priority threads that call this get what they asked for * even if that violates priority order. */ -kern_return_t thread_switch(thread_name, option, option_time) -mach_port_t thread_name; -int option; -mach_msg_timeout_t option_time; +kern_return_t thread_switch( + mach_port_t thread_name, + int option, + mach_msg_timeout_t option_time) { - register thread_t cur_thread = current_thread(); - register processor_t myprocessor; + thread_t cur_thread = current_thread(); + processor_t myprocessor; ipc_port_t port; /* @@ -210,7 +184,7 @@ mach_msg_timeout_t option_time; default: return(KERN_INVALID_ARGUMENT); } - + #ifndef MIGRATING_THREADS /* XXX thread_run defunct */ /* * Check and act on thread hint if appropriate. @@ -224,8 +198,8 @@ mach_msg_timeout_t option_time; * Get corresponding thread. */ if (ip_active(port) && (ip_kotype(port) == IKOT_THREAD)) { - register thread_t thread; - register spl_t s; + thread_t thread; + spl_t s; thread = (thread_t) port->ip_kobject; /* @@ -250,11 +224,11 @@ mach_msg_timeout_t option_time; myprocessor->quantum = thread->sched_data; myprocessor->first_quantum = TRUE; } -#endif MACH_FIXPRI +#endif /* MACH_FIXPRI */ counter(c_thread_switch_handoff++); thread_run(thread_switch_continue, thread); /* - * Restore depressed priority + * Restore depressed priority */ if (cur_thread->depress_priority >= 0) (void) thread_depress_abort(cur_thread); @@ -280,14 +254,14 @@ mach_msg_timeout_t option_time; myprocessor = current_processor(); if (myprocessor->processor_set->runq.count > 0 || myprocessor->runq.count > 0) -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ { counter(c_thread_switch_block++); thread_block(thread_switch_continue); } /* - * Restore depressed priority + * Restore depressed priority */ if (cur_thread->depress_priority >= 0) (void) thread_depress_abort(cur_thread); @@ -305,9 +279,9 @@ mach_msg_timeout_t option_time; * of zero will result in no timeout being scheduled. */ void -thread_depress_priority(thread, depress_time) -register thread_t thread; -mach_msg_timeout_t depress_time; +thread_depress_priority( + thread_t thread, + mach_msg_timeout_t depress_time) { unsigned int ticks; spl_t s; @@ -328,14 +302,14 @@ mach_msg_timeout_t depress_time; * sched_pri to their lowest possible values. */ thread->depress_priority = thread->priority; - thread->priority = 31; - thread->sched_pri = 31; + thread->priority = NRQS-1; + thread->sched_pri = NRQS-1; if (ticks != 0) set_timeout(&thread->depress_timer, ticks); thread_unlock(thread); (void) splx(s); -} +} /* * thread_depress_timeout: @@ -343,8 +317,7 @@ mach_msg_timeout_t depress_time; * Timeout routine for priority depression. */ void -thread_depress_timeout(thread) -register thread_t thread; +thread_depress_timeout(thread_t thread) { spl_t s; @@ -372,8 +345,7 @@ register thread_t thread; * Prematurely abort priority depression if there is one. */ kern_return_t -thread_depress_abort(thread) -register thread_t thread; +thread_depress_abort(thread_t thread) { spl_t s; @@ -397,3 +369,18 @@ register thread_t thread; (void) splx(s); return(KERN_SUCCESS); } + +/* + * mach_print + * + * Display a null-terminated character string on the Mach console. + * This system call is meant as a debugging tool useful to circumvent + * messaging altogether. + */ +#ifdef MACH_KDB +void +mach_print(const char *s) +{ + printf("%s", s); +} +#endif /* MACH_KDB */