Example #1
0
void _FIN(int sd){

  dem.procCounter--;

  printf("FIN(NUM OF PROCS:%d)\n",dem.procCounter);
  
  proc* p;
  int devNum,i;

  for(i = 0 ; i < dem.ndev ; i ++){
    if(dem.flags[i].sd == sd){
      printf("\tFIND FAILED PROC(SD:%d)\n",sd);
      dem.flags[i].flag = 0;
      dem.flags[i].sd   = 0;
    }
  }

  p = get_proc(sd);

  devNum = p->data->pos;

  remove_proc(p);

  dequeueSpecifyDevNO(devNum);
  
}
Example #2
0
static int DIVA_INIT_FUNCTION divadidd_init(void)
{
	char tmprev[32];
	int ret = 0;

	printk(KERN_INFO "%s\n", DRIVERNAME);
	printk(KERN_INFO "%s: Rel:%s  Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD);
	strcpy(tmprev, main_revision);
	printk("%s  Build:%s(%s)\n", getrev(tmprev),
	       diva_didd_common_code_build, DIVA_BUILD);

	if (!create_proc()) {
		printk(KERN_ERR "%s: could not create proc entry\n",
		       DRIVERLNAME);
		ret = -EIO;
		goto out;
	}

	if (!diddfunc_init()) {
		printk(KERN_ERR "%s: failed to connect to DIDD.\n",
		       DRIVERLNAME);
#ifdef MODULE
		remove_proc();
#endif
		ret = -EIO;
		goto out;
	}

      out:
	return (ret);
}
Example #3
0
static void exit_libcfs_module(void)
{
        int rc;

        remove_proc();

        CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
               cfs_atomic_read(&libcfs_kmemory));

        cfs_wi_shutdown();
        rc = cfs_psdev_deregister(&libcfs_dev);
        if (rc)
                CERROR("misc_deregister error %d\n", rc);

#if LWT_SUPPORT
        lwt_fini();
#endif

        if (cfs_atomic_read(&libcfs_kmemory) != 0)
                CERROR("Portals memory leaked: %d bytes\n",
                       cfs_atomic_read(&libcfs_kmemory));

        rc = libcfs_debug_cleanup();
        if (rc)
                printk(CFS_KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
                       rc);

        cfs_fini_rwsem(&ioctl_list_sem);
        cfs_fini_rwsem(&cfs_tracefile_sem);

        libcfs_arch_cleanup();
}
Example #4
0
/**
 * Starts a program
 */
void console_start(char *dir, char *command) {
    memset(senddir, 0, 64);
    strcpy(senddir, dir);
    strcat(senddir, "/");
    strcat(senddir, get_argument(command, 1));
    // Cut the arguments from the path
    if(get_argument(senddir, 1)) {
        strncpy(senddir, senddir, strlen(senddir) - strlen(get_argument(senddir, 1)) - 1);
    }

    char *arguments = kmalloc(128);
    memset(arguments, 0, 128);
    strcpy(arguments, get_argument(command, 2));

    int procn = start_proc(senddir, arguments);
    if(procn != PROC_STOPPED) {
        while(proc_state(procn) != PROC_STOPPED);
        remove_proc(procn);
        printk("\n");
    }
}
Example #5
0
static void exit_libcfs_module(void)
{
	int rc;

	remove_proc();

	CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
	       atomic_read(&libcfs_kmemory));

	if (cfs_sched_rehash != NULL) {
		cfs_wi_sched_destroy(cfs_sched_rehash);
		cfs_sched_rehash = NULL;
	}

	cfs_crypto_unregister();
	cfs_wi_shutdown();

	rc = misc_deregister(&libcfs_dev);
	if (rc)
		CERROR("misc_deregister error %d\n", rc);

#if LWT_SUPPORT
	lwt_fini();
#endif
	cfs_cpu_fini();

	if (atomic_read(&libcfs_kmemory) != 0)
		CERROR("Portals memory leaked: %d bytes\n",
		       atomic_read(&libcfs_kmemory));

	rc = libcfs_debug_cleanup();
	if (rc)
		printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
		       rc);

	fini_rwsem(&ioctl_list_sem);
	fini_rwsem(&cfs_tracefile_sem);

	libcfs_arch_cleanup();
}
Example #6
0
static int do_clone(struct task *task, struct task *newtask)
{
	debug(DEBUG_EVENT, "+++ process %s pid=%d, newpid=%d", get_clone_type(task->event.type), task->pid, newtask->pid);

	if (unlikely(options.verbose))
		fprintf(stderr, "+++ process %s pid=%d, newpid=%d\n", get_clone_type(task->event.type), task->pid, newtask->pid);

	assert(task->stopped);
	assert(newtask->stopped);
	assert(newtask->is_new);

	if (unlikely(options.verbose && newtask->event.type != EVENT_NEW))
		fprintf(stderr, "!!!task new unexpected event for pid=%d: %d\n", newtask->pid, newtask->event.type);
	else
	if (unlikely(options.verbose && newtask->event.e_un.signum))
		fprintf(stderr, "!!!task new unexpected signal for pid=%d: %d\n", newtask->pid, newtask->event.e_un.signum);

	if (newtask->leader == newtask) {
		if (task_fork(task, newtask) < 0)
			goto fail;

		if (!options.follow) {
			remove_proc(newtask);
			return RET_DELETED;
		}

		report_fork(newtask, task);
	}
	else {
		if (task_clone(task, newtask) < 0)
			goto fail;
	}

	newtask->is_new = 0;
	return continue_task(newtask, 0);
fail:
	fprintf(stderr, "Error during clone of pid=%d - This process won't be traced!\n", newtask->pid);
	return -1;
}
Example #7
0
int sem_up(struct proc *p, int sem)
{
	struct plist *waitp;

	if (sem < 0) {
		fprintf(stderr, "sem_up: invalid semaphor (pid %u)\n", p->pid);
		return 1;
	}
	if (sem_v(sem) != 0) {
		fprintf(stderr, "sem_up: error putting semaphor up (pid %u)\n", p->pid);
		return 1;

	}
	/* wake up the first waiting process, if any */
	waitp = sem_wq[sem].head;
	if (waitp == NULL)
		return 0;
	sched_resume(waitp->p->pid);
	if (remove_proc(&sem_wq[sem], waitp->p) != 0) {
		fprintf(stderr, "sem_up: error removing waiting proc from wait queue (pid %u)\n", p->pid);
		return 1;
	}
	return 0;
}
Example #8
0
static void DIVA_EXIT_FUNCTION divadidd_exit(void)
{
	diddfunc_finit();
	remove_proc();
	printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
}
Example #9
0
void _FIN(int sd){

  if(!has_proc_sd(sd)){

    cons* c;

    c = get_cons(sd);

    remove_cons(c);

    printf("CONS LEAVE\n");

    return;
  }

  dem.procCounter--;

  printf("FIN(SD:%d) (NUM OF PROCS:%d)\n",dem.procCounter);
  
  proc *p;
  int devNum,i;

  for(i = 0 ; i < dem.ndev ; i ++){
    if(dem.flags[i].sd == sd){
      printf("\tFIND FAILED PROC(SD:%d)\n",sd);
      dem.flags[i].flag = 0;
      dem.flags[i].sd   = 0;
    }
  }

  p = get_proc(sd);

  devNum = p->data->pos;

  printf("\tPID : %d\n",p->data->pid);

  if(!(p->data->flag&CANMIG)){

    printf("Staying proc @ %d finished.\n",devNum);

    dem.flags[devNum].stayed = 0;

    if(dem.staying_procs > 0){

      proc* stayp;

      stayp = (proc*)staying_proc();

      if(stayp == NULL){
	printf("oops ... failed to find staying proc...\n");
	exit(-1);
      }

      dem.staying_procs --;

      stayp->queued = ACTIVE;

      MSEND(stayp->sd,CONNECT,0,0,devNum,0,0);

      dem.flags[devNum].stayed = 1;
      
    }else{

      dequeueSpecifyDevNO(devNum);

    }
	
  }else{

    if(dem.flags[devNum].stayed){

      proc* ps;

      ps = (proc*)get_proc_staying_pos(devNum);

      if(ps == NULL){

	printf("PROC (CANNOT MIGRATE) IS ACTIVE NOW(%d)\n",devNum);

#if 0
	dequeueSpecifyDevNO(devNum);
#endif

      }else{

	nvmlReturn_t res;
	nvmlMemory_t mem;

	res = nvmlDeviceGetMemoryInfo(dem.devs[devNum],&mem);
      
	if(res != NVML_SUCCESS){
	  printf("Failed to get Memory Information\n");
	  exit(-1);
	}
      
	printf("USED : %u\n",ps->data->mem);
	printf("FREE : %u\n",mem.free);

	if(mem.free > ps->data->req + M64 + dem.flags[devNum].reserved){

	  MSEND(ps->sd,GOAHEAD,0,0,devNum,0,0);

	  ps->queued = ACTIVE;

	}
#if 0
	else{
	
	  dequeueSpecifyDevNO(devNum);
	
	}
#endif

      }

    }else{

      if(dem.staying_procs > 0){

	proc* ps;

	ps = staying_proc();

	if(ps == NULL){
	  printf("What ...? 1\n");
	  exit(-1);
	}

	MSEND(ps->sd,CONNECT,0,0,devNum,0,0);

	dem.staying_procs --;

	dem.flags[devNum].stayed = 1;

	ps->queued = ACTIVE;
	
      }else{

	dequeueSpecifyDevNO(devNum);

      }
    }
  }

  cons_remove(p);
    
  remove_proc(p);
}