student-distrib/system_call.c
int32_t find_bottom_task(uint32_t task_num) {
	pcb_t* process_control_block;
	
	// If invalid task_num, error
	if((task_num < 0) || (task_num > 2))
		return -1;
		
	// If given task_num isn't running, error
	if(task_slots[task_num] == 0)
		return -1;
	
	process_control_block = get_pcb(task_num);
	// Go until no child task
	while(process_control_block->task_id_child != -1) {
		process_control_block = get_pcb(process_control_block->task_id_child);
	}
	
	return process_control_block->task_id;
}
/* find_bottom_task()
 * Input: entry to check for a child
 * Return: entry number for bottom of task chain, -1 for error
 * Effect: find the bottom running task for a chain of tasks
 */
find_bottom_task()
Input: entry to check for a child
Return: entry number for bottom of task chain, -1 for error
Effect: find the bottom running task for a chain of tasks
find_bottom_task () Input : entry to check for a child Return : entry number for bottom of task chain - 1 for error Effect : find the bottom running task for a chain of tasks
int32_t find_bottom_task(uint32_t task_num) {
	pcb_t* process_control_block;
	if((task_num < 0) || (task_num > 2))
		return -1;
	if(task_slots[task_num] == 0)
		return -1;
	process_control_block = get_pcb(task_num);
	while(process_control_block->task_id_child != -1) {
		process_control_block = get_pcb(process_control_block->task_id_child);
	}
	return process_control_block->task_id;
}
int32_t find_bottom_task ( uint32_t task_num ) { pcb_t * process_control_block ; if ( ( task_num < 0 ) || ( task_num > 2 ) ) return -1 ; if ( task_slots [ task_num ] == 0 ) return -1 ; process_control_block = get_pcb ( task_num ) ; while ( process_control_block -> task_id_child != -1 ) { process_control_block = get_pcb ( process_control_block -> task_id_child ) ; } return process_control_block -> task_id ; }
find_bottom_task()
 Input: entry to check for a child
 Return: entry number for bottom of task chain, -1 for error
 Effect: find the bottom running task for a chain of tasks
find_bottom_task () Input : entry to check for a child Return : entry number for bottom of task chain - 1 for error Effect : find the bottom running task for a chain of tasks
// If invalid task_num, error // If given task_num isn't running, error // Go until no child task