jos_c2 - jos.c starting point for student's

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * jos.c -- starting point for student's os. * */ #include "simulator.h" #include "jos.h" #include "jrb.h" #include "jval.h" #include "dllist.h" #include <thread.h> #include <string.h> #define MAX_OS_THREADS 10 #define MAX_SYSTEM_CALLS_PER_OS_THREAD 10 typedef void * (*RunFunction)(void *); JOS_GLOBALS JG; /*static char *Argv[5]={ "argtest","Rex,","my","man!",NULL };*/ static char *Argv[2]={ "a.out",NULL}; /* Called once to initialize the global variables */ initialize_global_jos_state() { int i; Mem_Slot **mem_slot; int slot=MemorySize/8; JRB p; Mem_Slot *t; /* start_timer(10); */ JG.readyq = new_dllist(); JG.nulljob = (PCB *) malloc(sizeof(PCB)); /* This doesn't do anything, but gives me a place holder for noop() jobs */ JG.nextin=0; JG.nextout=0; JG.jrb_pid=make_jrb(); JG.jrb_mem=make_jrb(); JG.sentinel_pcb=(PCB *)malloc(sizeof(PCB)); JG.sentinel_pcb->pid=get_new_pid(); sema_init(&JG.sentinel_pcb->waiter_sem,0,USYNC_THREAD,NULL); JG.sentinel_pcb->waiters=new_dllist(); JG.sentinel_pcb->children=make_jrb(); jrb_insert_int(JG.jrb_pid,JG.sentinel_pcb->pid,new_jval_v(NULL)); mem_slot=(Mem_Slot **)malloc(sizeof(Mem_Slot *)*8); for(i=0;i<8;i++) { mem_slot[i]=(Mem_Slot *)malloc(sizeof(Mem_Slot)); mem_slot[i]->base=i*slot; mem_slot[i]->limit=slot; jrb_insert_int(JG.jrb_mem,i,new_jval_v((void *)mem_slot[i])); }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
sema_init(&JG.writeok,0,USYNC_THREAD,NULL); sema_init(&JG.consoleWait,0,USYNC_THREAD,NULL); sema_init(&JG.nelem,0,USYNC_THREAD,NULL); sema_init(&JG.writers,1,USYNC_THREAD,NULL);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2009 for the course CS cs170 taught by Professor Wolski during the Fall '09 term at UCSB.

Page1 / 5

jos_c2 - jos.c starting point for student's

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online