void initNewProgram(u_int32_t codeSize, char* programSourceCode, int consoleSocket){
	PCB* nuevoPCB;
	nuevoPCB = new_pcb(consoleSocket);
	int memoryPagesCount;
	memoryPagesCount = getProgramPagesCount(programSourceCode);
	create_program_PCB(nuevoPCB, programSourceCode, memoryPagesCount);
	//TODO:Sacar linea
	//add_pcb_to_general_list(nuevoPCB);

	//Envío solicitud de páginas a UMC
	umc_initProgram(memoryPagesCount, nuevoPCB, codeSize, programSourceCode);
}
Example #2
0
File: sos.c Project: ldfaiztt/MSCS
SOS()
{
        readyq = new_dllist();
        mt_init();
        writeok     = mt_sem_create(0);
        writers     = mt_sem_create(1);
        readers     = mt_sem_create(1);
        nelem       = mt_sem_create(0);
        consoleWait = mt_sem_create(0);
        
        wr_iobuf = make_io_buffer(1);
        cr_iobuf = make_io_buffer(256);
        crb_no_chars = 0;
        crb_end = 0; 
        crb_begin = 0;

        curpid = -1;
//      pids = make_rb();
        init_partitions(); 
        DEBUG('e', "pagesize: %d\n", PageSize);

	jrbTree = make_jrb();		// Step 20

	init = new_pcb();		// Step 22
	init->pid = get_new_pid();	// Step 22
   
        cread_vnode = new_vnode();
        cread_vnode->iobuf =cr_iobuf;
        cr_iobuf->nwriters = 1;
        cwrite_vnode = new_vnode();               
        cwrite_vnode->iobuf = wr_iobuf;
        wr_iobuf->nreaders = 1;
        
        start_timer(10);	
	bzero(main_memory, MemorySize);
        mt_create(read_console_io, (void *)cr_iobuf);
        mt_create(write_console_io, (void *)wr_iobuf);
        //mt_create(read_console, NULL);
        mt_create(initialize_user_process, (void *)Argv);
        schedule();
}
Example #3
0
int dispatcher_init()
{
	fprintf(stdout, "\t[+] dispatcher_init():\n");
	fprintf(stdout, "\t[+] dispatcher_init(): Creating ready list.\n");
	ready = new_list();
	fprintf(stdout, "\t[+] dispatcher_init(): Creating blocked list.\n");
	blocked = new_list();

	fprintf(stdout, "\t[+] dispatcher_init(): Creating dispatcher_context pcb.\n");
	dispatcher_context = new_pcb();

	makecontext(dispatcher_context->context, (void *)(dispatcher), 0);
	dispatcher_context->pid = 0;
	dispatcher_context->prio = 2;

	fprintf(stdout, "\t[+] dispatcher_init(): setting the current running process as the dispatcher.\n");
	running_proc = dispatcher_context;

	current_pid = 1;

	return 1;
}