#define MAX_OS_THREADS 3 typedef ">

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

Info icon This preview shows pages 1–2. Sign up to view the full content.

/* * jos.c -- starting point for student's os. * */ #include "simulator.h" #include "jos.h" #include <thread.h> #define MAX_OS_THREADS 3 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() { 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; 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); sema_init(&JG.readers,1,USYNC_THREAD,NULL); } initialize_user_process(char **filename) { int i,k,argc,argv; PCB *init_pcb; int *argv_ptr; int tos; int temp; argc=1; argv_ptr=(int *)malloc(sizeof(int)*argc); bzero(main_memory,MemorySize); if(temp=load_user_program(filename[0]) <0) { fprintf(stderr,"Can't load program.\n"); exit(1); } printf("load user program return %d\n",temp); init_pcb=(PCB *) malloc(sizeof(PCB)); for(i=0;i<NumTotalRegs;i++) init_pcb->regs[i]=0;
Image of page 1

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

Image of page 2
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