コード例 #1
0
ファイル: gemdisp.c プロジェクト: ragnar76/emutos
static void disp_act(PD *p)
{      
                                                /* process is ready,    */
                                                /*   so put him on RLR  */
        p->p_stat &= ~WAITIN;
        insert_process(p, &rlr);        
}
コード例 #2
0
/* Function reads input data from a file, saves data as a process, 
   and returns the queue with all proceses waiting to be loaded into memory */
process_t *read_processes(char *file, process_t *queue)
{
	int process_num;
	int process_size;
	int first_read = 1;
	FILE *fp;
	char line[MAXLINE];     

	/* Open file for reading, check if file is empty */
	if( (fp=fopen(file,"r")) ==NULL)
	{
		printf("Error file %s is empty.\n", file);
		exit(1);
	}

	/* Read from file  */
	while(fgets(line, sizeof(line), fp))
	{
		sscanf(line, "%d %d", &process_num, &process_size);

		if(DEBUGLINE)
			printf("Line Read: PID - %d, MEMORY - %d \n", process_num, process_size);

		if(first_read)
		{
			/* If its the first line, put data at start of queue */
			insert_process(queue, process_num, process_size, 0, 0, 0);
			first_read = 0;
			continue;
		}

		/* Allocate memory for new process and push onto the queue */
		process_t *process_read = safe_malloc(sizeof(process_t));
		insert_process(process_read, process_num, process_size, 0, 0, 0);
		push(queue, process_read);

	}

	return queue;

}
コード例 #3
0
ファイル: shell.c プロジェクト: sarthak-0415/shell
process * parse( char *line)
{
	//puts(line);
	process * head=NULL;

	while(*line != '\0')
		line= insert_process(&head, line);
		
	display_process(head);
	
	return head;
}
コード例 #4
0
ファイル: memory.c プロジェクト: Bhavya/Pea-OS
void unblock_single_waiting_process(){
	pcb * temp;
	int i;
	for(i=0; i<4; i++){
		temp = bmem_queue[i];
		if(temp == NULL) continue;
		while(temp->next_process != NULL){
			temp = temp->next_process;
		} 
		insert_process(remove_blocked_process(temp,BLOCKED_MEM_STATE), temp->process_priority);
	}
	return;
}
コード例 #5
0
/* Removes the next process from the list and returns it */
process_t* pop(process_t **queue)
{
	process_t *start_process = safe_malloc(sizeof(process_t));
	process_t *next_node = NULL;

	/* Update pointers so the start of the queue points to correct position */
	next_node = (*queue)->next;
	insert_process(start_process, (*queue)->PID, (*queue)->size, (*queue)->run_time, 
		(*queue)->index_flag, 0);

	free(*queue);
	*queue = next_node;

	return start_process;
}