コード例 #1
0
static gboolean view_release_event(GtkWidget *view, GdkEventButton *event, gpointer user_data){
    if(event->button!=1) return FALSE;
    GtkTreePath *path=NULL;
    GtkTreeViewColumn *column=NULL;
    if(gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(view),
				     (gint)event->x,
				     (gint)event->y,
				     &path, &column, NULL, NULL)){
	const gchar *title=gtk_tree_view_column_get_title(column);
	if(!strcmp(title," ")){
	    GtkTreeIter iter;
	    gint ihost=GPOINTER_TO_INT(user_data);
	    GtkTreeModel *model=GTK_TREE_MODEL(lists[ihost]);
	    gtk_tree_model_get_iter(model, &iter, path);
	    GValue value=G_VALUE_INIT;
	    gtk_tree_model_get_value(model, &iter, COL_PID, &value);
	    int pid=strtol(g_value_get_string(&value), NULL, 10);
	    g_value_unset(&value);
	    PROC_T *p=proc_get(ihost, pid);
	    if(p){
		if(p->status.info<10){
		    kill_job(p);
		}else{
		    scheduler_cmd(ihost, pid, CMD_REMOVE);
		}
	    }
	}
    }
    return TRUE;
}
コード例 #2
0
ファイル: module.c プロジェクト: grahamedgecombe/arc
void module_init(multiboot_t *multiboot)
{
  /*
   * disable interrupts, module loading messes around with address space
   * switches so we don't want to confuse the scheduler
   */
  intr_lock();

  /* keep a copy of the old process */
  proc_t *old_proc = proc_get();

  multiboot_tag_t *tag = multiboot_get(multiboot, MULTIBOOT_TAG_MODULE);
  while (tag)
  {
    module_load(tag);
    tag = multiboot_get_after(multiboot, tag, MULTIBOOT_TAG_MODULE);
  }

  /* switch back to the correct address space */
  if (old_proc)
    proc_switch(old_proc);

  /* enable interrupts again */
  intr_unlock();
}
コード例 #3
0
ファイル: csl.c プロジェクト: Tayyib/uludag
static PyObject *
c_call(PyObject *self, PyObject *args)
{
	struct ipc_struct ipc;
	struct pack *p;
	char *node;
	char *pak;
	int nd;

	if (!PyArg_ParseTuple(args, "ss", &node, &pak))
		return NULL;

	nd = model_lookup_method(node);
	if (nd == -1) return NULL;

	memset(&ipc, 0, sizeof(struct ipc_struct));
	ipc.node = nd;
	p = pack_new(128);
	pack_put(p, pak, strlen(pak));

	job_start(CMD_CALL_PACKAGE, &ipc, p);

	while (1) {
		struct ProcChild *sender;
		int cmd;
		int size;

		if (1 == proc_listen(&sender, &cmd, &size, 1)) {
			switch (cmd) {
				case CMD_RESULT:
				case CMD_FAIL:
				case CMD_ERROR:
				case CMD_NONE:
					proc_get(sender, &ipc, p, size);
					break;
				case CMD_NOTIFY:
					proc_get(sender, &ipc, p, size);
					proc_put(TO_PARENT, cmd, &ipc, p);
					break;
			}
			if (cmd == CMD_FINISH) break;
		}
	}
	Py_INCREF(Py_None);
	return Py_None;
}
コード例 #4
0
ファイル: gui.c プロジェクト: funglaub/utop
void goto_lock(struct myproc **procs)
{
  if(lock_proc_pid == -1){
    attron( COLOR_PAIR(1 + COLOR_RED));
    WAIT_STATUS("no process locked on");
    attroff(COLOR_PAIR(1 + COLOR_RED));
  }else{
    goto_proc(procs, proc_get(procs, lock_proc_pid));
  }
}
コード例 #5
0
ファイル: monitor_thread.c プロジェクト: lianqiw/maos
static PROC_T *proc_add(int id,int pid){
    PROC_T *iproc;
    if((iproc=proc_get(id,pid))) return iproc;
    iproc=mycalloc(1,PROC_T);
    iproc->iseed_old=-1;
    iproc->pid=pid;
    iproc->hid=id;
    LOCK(mhost);
    iproc->next=pproc[id];
    pproc[id]=iproc;
    nproc[id]++;
    gdk_threads_add_idle((GSourceFunc)update_title, GINT_TO_POINTER(id));
    UNLOCK(mhost);
    return iproc;
}
コード例 #6
0
ファイル: job.c プロジェクト: Tayyib/uludag
static void
job_proc(void)
{
	struct ipc_struct ipc;
	struct pack *p;
	struct ProcChild *sender;
	char *t, *s;
	int cmd;
	size_t size;

	p = pack_new(256);
	while (1) {
		if (1 == proc_listen(&sender, &cmd, &size, 1)) break;
	}
	proc_get(sender, &ipc, p, size);

	bk_channel = ipc.source;

	switch (cmd) {
		case CMD_REGISTER:
			pack_get(p, &t, NULL);
			pack_get(p, &s, NULL);
			do_register(ipc.node, t, s);
			break;
		case CMD_REMOVE:
			pack_get(p, &t, NULL);
			do_remove(t);
			break;
		case CMD_CALL:
			do_call(ipc.node, p);
			break;
		case CMD_CALL_PACKAGE:
			pack_get(p, &t, NULL);
			do_call_package(ipc.node, t, p);
			break;
		case CMD_GETLIST:
			do_getlist(ipc.node);
			break;
		case CMD_DUMP_PROFILE:
			do_dump_profile();
			break;
		case CMD_EVENT:
			pack_get(p, &t, NULL);
			pack_get(p, &s, NULL);
			do_event(t, ipc.node, s, p);
			break;
	}
}
コード例 #7
0
ファイル: machine_ps.c プロジェクト: bobrippling/utop
void machine_proc_get_more(struct myproc **procs)
{
    ps_update();

    for(size_t i = 0; i < ps_n; i++) {
        pid_t pid, ppid;

        if(sscanf(ps_list[i], " %d %d ", &pid, &ppid) == 2
                && !proc_get(procs, pid))
        {
            struct myproc *p = umalloc(sizeof *p);

            /* bare minimum - rest is done in _update */
            p->pid  = pid;
            p->ppid = ppid;

            proc_addto(procs, p);
        } else {
            //fprintf(stderr, "couldn't sscanf(\"%s\")\n", ps[i]);
        }
    }
}
コード例 #8
0
ファイル: job.c プロジェクト: Tayyib/uludag
static int
do_call(int node, struct pack *pak)
{
	struct pack *p = NULL;
	char *apps;
	int ok = 0;

	log_debug(LOG_JOB, "Call(%s)\n", model_get_path(node));

	if (model_flags(node) & P_GLOBAL) {
		p = pack_dup(pak);
	}

	if (db_get_apps(model_parent(node), &apps) != 0) {
		send_result(CMD_NONE, "noapp", 5);
		// FIXME: ok diyecek betik yoksa profile kayıt etmeli mi acaba
		exit(1);
	}

	if (strchr(apps, '/') == NULL) {
		// there is only one script
		if (0 == do_execute(node, apps, pak))
			ok = 1;
	} else {
		// multiple scripts, run concurrently
		char *t, *s;
		struct ProcChild *p;
		int cmd;
		int cnt = 0;
		size_t size;

		// FIXME: package count
		send_result(CMD_RESULT_START, NULL, 0);
		for (t = apps; t; t = s) {
			s = strchr(t, '/');
			if (s) {
				*s = '\0';
				++s;
			}
			bk_node = node;
			bk_app = t;
			bk_pak = pak;
			p = proc_fork(exec_proc, "ComarSubJob");
			if (p) {
				++cnt;
			} else {
				send_result(CMD_ERROR, "fork failed", 11);
			}
		}
		while(1) {
			struct ipc_struct ipc;
			struct pack *pak;
			pak = pack_new(128);
			proc_listen(&p, &cmd, &size, -1);
			if (cmd == CMD_FINISH) {
				--cnt;
				if (!cnt) break;
			} else {
				if (cmd == CMD_RESULT) ok++;
				proc_get(p, &ipc, pak, size);
				proc_put(TO_PARENT, cmd, &ipc, pak);
			}
		}
		send_result(CMD_RESULT_END, NULL, 0);
	}

    if ((model_flags(node) & P_GLOBAL) && ok) {
		db_put_profile(node, NULL, p);
		pack_delete(p);
	}

	return 0;
}
コード例 #9
0
ファイル: monitor_thread.c プロジェクト: lianqiw/maos
//respond to scheduler
static int respond(int sock){
    int cmd[3];
    //read fixed length header info.
    if(streadintarr(sock, cmd, 3)){
	return -1;//failed
    }
    int ihost=host_from_sock(sock);
    if(ihost>=0){
	htime[ihost]=myclockd();
    }
    int pid=cmd[2];
    switch(cmd[0]){
    case -1:{//server request shutdown
	info("disconnect from %s\n", hosts[ihost]);
	return -1;
    }
	break;
    case MON_VERSION:
	break;
    case MON_STATUS:
	{
	    if(ihost<0){
		warning("Host not found\n");
		return -1;
	    }
	    PROC_T *p=proc_get(ihost,pid);
	    if(!p){
		p=proc_add(ihost,pid);
	    }
	    if(stread(sock, &p->status, sizeof(STATUS_T))){
		return -1;
	    }
	    if(p->status.info==S_REMOVE){
		proc_remove(ihost, pid);
	    }else{
		if(cmd[1]!=ihost && cmd[1]!=cmd[2]){
		    /*A new mean to replace the ID of a job.*/
		    p->pid=cmd[1];
		}
		gdk_threads_add_idle((GSourceFunc)refresh, p);
	    }
	}
	break;
    case MON_PATH:
	{
	    if(ihost<0){
		warning("Host not found\n");
		return -1;
	    }
	    PROC_T *p=proc_get(ihost,pid);
	    if(!p){
		p=proc_add(ihost,pid);
	    }
	    if(streadstr(sock, &p->path)){
		return -1;
	    }
	    char *tmp=NULL;
	    while((tmp=strchr(p->path, '\n'))){
		tmp[0]=' ';
	    }
	}
	break;
    case MON_LOAD:
	{
	    if(ihost<0){
		warning("Host not found\n");
		return -1;
	    }
	    usage_cpu[ihost]=(double)((pid>>16) & 0xFFFF)/100.;
	    usage_mem[ihost]=(double)(pid & 0xFFFF)/100.;
	    usage_cpu[ihost]=MAX(MIN(1,usage_cpu[ihost]),0);
	    usage_mem[ihost]=MAX(MIN(1,usage_mem[ihost]),0);
	    gdk_threads_add_idle((GSourceFunc)update_progress, GINT_TO_POINTER(ihost));
	}
	break;
    case MON_ADDHOST:
	if(cmd[1]>-1 && cmd[1]<nhost){
	    pthread_t tmp;
	    pthread_create(&tmp, NULL, (void*(*)(void*))add_host, GINT_TO_POINTER(cmd[1]));
	}else if(cmd[1]==-2){
	    return -2;
	}
	break;
    default:
	warning_time("Invalid cmd %d\n",cmd[0]);
	return -1;
    }
    return 0;
}
コード例 #10
0
ファイル: gui.c プロジェクト: funglaub/utop
struct myproc *gui_proc_first(struct myproc **procs)
{
  struct myproc *init = proc_get(procs, 0); // the root node
  return init;
}
コード例 #11
0
ファイル: gui.c プロジェクト: funglaub/utop
void goto_me(struct myproc **procs)
{
  goto_proc(procs, proc_get(procs, getpid()));
}