Ejemplo n.º 1
0
int check_deadlock(osprd_info_t *d)
{
	//osp_spin_lock(&d->mutex);
	pid_list_t depend_head = d->check_deadlock_list_head;
	pid_list_t depend_tail = d->check_deadlock_list_tail;
	pid_list_t p = depend_head;
	if (p == NULL)
	{
		//osp_spin_unlock(&d->mutex);
		return 0;
	}
	eprintk ("haha1");
	if(pid_in_list(depend_head,depend_tail,current->pid,1))
	{	
		eprintk ("before return 1");
		//osp_spin_unlock(&d->mutex);
		return 1;
	}
	int i = 0;
	while(i < NOSPRD)
	{
		eprintk("in while loop");
		osprd_info_t *od = &osprds[i];
			if (od == d)
				continue;
		osp_spin_lock(&od->mutex);
		pid_list_t od_head = od->check_deadlock_list_head;
		pid_list_t od_tail = od->check_deadlock_list_tail;
		while(p!=NULL)
		{
			eprintk ("in second while loop");
			if(pid_in_list(od_head,od_tail,p->pid,0))
				{
					int count = find_pid_list(od_head,od_tail,p->pid);
					if(find_until_count(od_head,od_tail,current->pid,count))
						{
							eprintk ("before return1~");
							
							return 1;
						}
				}
			p = p->next;
				
		}
		osp_spin_unlock(&od->mutex);
		i++;

	}
	eprintk ("before return 0");
	//osp_spin_unlock(&od->mutex);
	return 0;
}
Ejemplo n.º 2
0
void terminationHandler(int signum, siginfo_t *info, void *context){
	Pid_List process = find_pid_list(pidTable, info->si_pid);
	//printf("info: %p, pid: %d, uid: %d\n", info, info->si_pid, info->si_uid);
	if(process == NULL){
		printf("Process %d terminated\n", info->si_pid);
	}
	else{
		if(!process->background){
			return;
		}
		struct timeval time;
		gettimeofday(&time, NULL);
		printf("Process %d:%s terminated after %ldms\n", process->pid, process->command, (-process->time.tv_sec + time.tv_sec)*1000+(-process->time.tv_usec+time.tv_usec)/1000);
	}
}