[BACK]Return to kern_time.c CVS log [TXT][DIR] Up to [local] / funnyos / kern

File: [local] / funnyos / kern / kern_time.c (download)

Revision 1.2, Fri Nov 23 13:37:43 2007 UTC (16 years, 5 months ago) by nbrk
Branch: MAIN
Changes since 1.1: +4 -3 lines

basic roundrobin multitasking support in FunnyOS!
_vector_irq saves Sys_mode context (which is treated as struct pcb) in stack and
passes sp to irq_trampoline() which then sets global iframep pointer to point to pcb of interrupted task.

"task" given by u_task (set by user at compile-time) and k_task which is dynamically allocated by the kernel.
scheduler uses list of k_task (circularly linked list) with one constant task "idle".
idle discarded in sched_init() with status TASK_NOSCHED and will not be scheduled after first sched_tick().

tasks created in task/ directory and should implement void ttt_enter(void) to start execution from.
tasks added by inserting new elements in config_tasklist[].

please note that current *ugly* design causes strange behavior if tasks printf something w/out delays..
also, we do not save task's CPSR yet..

/*
 * $Id: kern_time.c,v 1.2 2007/11/23 13:37:43 nbrk Exp $
 */
#include <sys/types.h>
#include <sys/kern_time.h>
#include <sys/kern_sched.h>

#include <libkern/printf.h>

/*
 * Kernel time-related stuff.
 */

struct rtcops 	sysrtcops = {NULL, NULL, NULL};	/* system will use this to control rtc hardware */
struct timedata systimedata;


void
sysclock_init(void)
{
	/*
	 * Start system clock.
	 */
	/* panic if driver haven't configured rtcops for us */
	if (sysrtcops.ro_sethz == NULL)
		panic("sysclock_init: clock init failed; can't find rtc driver entry points (sysrtcops is null)\n");

	/* configure hardware */
	sysrtcops.ro_sethz(HZ);

}


void
sysclock(void)
{
	/*
	 * Process one system tick.
	 * RTC interrupt handler will call us; remember that we are in interrupt mode here.
	 */

	/* update time data */
	systimedata.td_seconds = sysrtcops.ro_getsec();

	/* TODO kick scheduler */
	sched_tick();
}