jos_c2 - jos.c starting point for student's...

Info icon This 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])); }
Image of page 1

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

View Full Document Right 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);
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern