Exemplo n.º 1
0
  void NativeMethod::init(STATE) {
    GO(nmethod).set(ontology::new_class(state, "NativeMethod",
          G(executable), G(rubinius)));
    G(nmethod)->set_object_type(state, NativeMethodType);

    init_thread(state);
  }
Exemplo n.º 2
0
BOOL thread_create(const char *name,
                   diegos_prio_t prio,
                   void (*entry_ptr)(void),
                   void *stack,
                   unsigned stack_size,
                   uint8_t *tid)
{
    uint8_t ntid;

    if (!tid || !stack_size || !entry_ptr || !name) {
        return (FALSE);
    }

    ntid = init_thread(name, prio, entry_ptr, stack, stack_size);

    if (THREAD_TID_INVALID == ntid) {
        kerrprintf("cannot init a new thread.\n");
        return (FALSE);
    }

    if (!scheduler_add_thread(ntid)) {
        kernel_panic("cannot schedule a thread.\n");
        return (FALSE);
    }

    *tid = ntid;

    return (TRUE);
}
Exemplo n.º 3
0
static void *
thread(void *unsafectx){
	ctx x = *(ctx *)unsafectx;
	CUcontext cu;

	if(init_thread(&cu,x.dev,x.s)){
		goto err;
	}
	pthread_mutex_lock(&lock);
	printf("Got context at %p\n",cu);
	thrdone = 1;
	pthread_cond_broadcast(&cond);
	while(threadsmaintain){
		pthread_cond_wait(&cond,&lock);
	}
	pthread_mutex_unlock(&lock);
	return NULL;

err:
	pthread_mutex_lock(&lock);
	thrdone = 1;
	threadsmaintain = 0;
	pthread_cond_broadcast(&cond);
	pthread_mutex_unlock(&lock);
	return NULL;
}
Exemplo n.º 4
0
/* Initializes the threading system by transforming the code
   that's currently running into a thread.  This can't work in
   general and it is possible in this case only because loader.S
   was careful to put the bottom of the stack at a page boundary.

   Also initializes the run queue and the tid lock.

   After calling this function, be sure to initialize the page
   allocator before trying to create any threads with
   thread_create().

   It is not safe to call thread_current() until this function
   finishes. */
void
thread_init (void) 
{
  ASSERT (intr_get_level () == INTR_OFF);

  lock_init (&tid_lock);

  if(thread_mlfqs) {
	load_avg = 0;
	f = 1 << q;
	int i;
	for(i=0;i<PRI_MAX+1;i++) list_init (&ready_mlfqs[i]);
  } else {
	list_init (&ready_list);
  }

  list_init (&all_list);
  list_init (&waiting_list);

  /* Set up a thread structure for the running thread. */
  initial_thread = running_thread ();
  init_thread (initial_thread, "main", PRI_DEFAULT);
  initial_thread->status = THREAD_RUNNING;
  initial_thread->tid = allocate_tid ();
}
Exemplo n.º 5
0
Arquivo: preload.c Projeto: passimm/rr
init_process(void)
{
	assert(!process_inited);

	if (getenv("_RR_CHECK_PRELOAD")) {
		/* The tracer parent is just checking that we loaded.
		 * We did, so return a success code. */
		exit(0);
	}

	real_pthread_create = dlsym(RTLD_NEXT, "pthread_create");
	real_pthread_mutex_timedlock = dlsym(RTLD_NEXT, "pthread_mutex_timedlock");

	buffer_enabled = !!getenv(SYSCALLBUF_ENABLED_ENV_VAR);
	if (!buffer_enabled) {
		debug("Syscall buffering is disabled");
		process_inited = 1;
		return;
	}

	pthread_atfork(NULL, NULL, post_fork_child);

	install_syscall_filter();
	rrcall_monkeypatch_vdso(&_vsyscall_hook_trampoline);
	process_inited = 1;

	init_thread();
}
Exemplo n.º 6
0
ffemu_t *ffemu_new(const struct ffemu_params *params)
{
   av_register_all();

   ffemu_t *handle = (ffemu_t*)calloc(1, sizeof(*handle));
   if (!handle)
      goto error;

   handle->params = *params;

   if (!ffemu_init_video(&handle->video, &handle->params))
      goto error;

   if (!ffemu_init_audio(&handle->audio, &handle->params))
      goto error;

   if (!ffemu_init_muxer(handle))
      goto error;

   if (!init_thread(handle))
      goto error;

   return handle;

error:
   ffemu_free(handle);
   return NULL;
}
Exemplo n.º 7
0
static int init(struct parasite_init_args *args)
{
	int ret;

	if (!args->nr_threads)
		return -EINVAL;

	tid_state = (void *)sys_mmap(NULL, TID_STATE_SIZE(args->nr_threads),
				     PROT_READ | PROT_WRITE,
				     MAP_PRIVATE | MAP_ANONYMOUS,
				     -1, 0);
	if ((unsigned long)tid_state > TASK_SIZE)
		return -ENOMEM;

	nr_tid_state = args->nr_threads;

	ret = init_thread();
	if (ret < 0)
		return ret;

	tsock = sys_socket(PF_UNIX, SOCK_DGRAM, 0);
	if (tsock < 0)
		return tsock;

	ret = sys_bind(tsock, (struct sockaddr *) &args->p_addr, args->p_addr_len);
	if (ret < 0)
		return ret;

	ret = sys_connect(tsock, (struct sockaddr *)&args->h_addr, args->h_addr_len);
	if (ret < 0)
		return ret;

	return 0;
}
Exemplo n.º 8
0
static void *ffmpeg_new(const struct ffemu_params *params)
{
   av_register_all();
   avformat_network_init();

   ffmpeg_t *handle = (ffmpeg_t*)calloc(1, sizeof(*handle));
   if (!handle)
      goto error;

   handle->params = *params;

   if (!ffmpeg_init_config(&handle->config, params->config))
      goto error;

   if (!ffmpeg_init_muxer_pre(handle))
      goto error;

   if (!ffmpeg_init_video(handle))
      goto error;

   if (handle->config.audio_enable && !ffmpeg_init_audio(handle))
      goto error;

   if (!ffmpeg_init_muxer_post(handle))
      goto error;

   if (!init_thread(handle))
      goto error;

   return handle;

error:
   ffmpeg_free(handle);
   return NULL;
}
Exemplo n.º 9
0
//executes 1 command line
void execute_command(char * command_line){
    
    if (command_line[0]=='#') return; //=comments
    
    if (write_to_thread_buffer){
        if (strncmp(command_line, "thread_stop", 11)==0){
            if (mode==MODE_TCP){
                write_to_thread_buffer=0;
                if (debug) printf("Thread stop.\n");
                if (thread_write_index>0) start_thread=1; //remember to start the thread when client closes the TCP/IP connection
            }        
        }else{
            if (debug) printf("Write to thread buffer: %s\n", command_line);
            while (*command_line!=0){
                write_thread_buffer(*command_line); //for TCP/IP we write to the thread buffer
                command_line++;
            }
            write_thread_buffer(';');
        }
    }else{
 
        char * arg = strchr(command_line, ' ');
        char * command =  strtok(command_line, " \r\n");    
        
        if (arg!=NULL) arg++;
        
        if (strcmp(command, "render")==0){
            render(arg);
        }else if (strcmp(command, "rotate")==0){
            rotate(arg);
        }else if (strcmp(command, "delay")==0){
            if (arg!=NULL)	usleep((atoi(arg)+1)*1000);
        }else if (strcmp(command, "brightness")==0){
            brightness(arg);
        }else if (strcmp(command, "rainbow")==0){
            rainbow(arg);
        }else if (strcmp(command, "fill")==0){	
            fill(arg);
        }else if (strcmp(command, "do")==0){
            start_loop(arg);
        }else if (strcmp(command, "loop")==0){
            end_loop(arg);
        }else if (strcmp(command, "thread_start")==0){ //start a new thread that processes code
            if (thread_running==0 && mode==MODE_TCP) init_thread(arg);
        }else if (strcmp(command, "setup")==0){
            setup_ledstring(arg);
        }else if (strcmp(command, "settings")==0){
            print_settings();
        }else if (strcmp(command, "debug")==0){
            if (debug) debug=0;
            else debug=1;
        }else if (strcmp(command, "exit")==0){
            printf("Exiting.\n");
            exit_program=1;
        }else{
            printf("Unknown cmd: %s\n", command_line);
        }
    }
}
Exemplo n.º 10
0
void* 
monitor_init_thread(unsigned tid)
{
  if (opt_debug >= 1) {
    fprintf(stderr, "init_thread(TID=0x%ux) callback from monitor received\n", tid);
  }
  return((void *)init_thread(1));
}
Exemplo n.º 11
0
Arquivo: test.c Projeto: fazhar/e2d2
void *thr(void* arg)
{
	struct node* n = arg;
	struct rte_mbuf* restrict pkts[32];
	int i;
	int q = n->queue;
	int start_sec = cursec();
	int rcvd = 0;
	int sent = 0;
	init_thread(n->tid, n->core);
	if (q >= 20) {
		printf("Somehow, queue beyond 20\n");
	}
	while(1) {
		/*int recv;*/
		i = mbuf_alloc_bulk(pkts, 60, 32);
		if (i != 0) {
			printf("Error allocating packets %d\n", i);
			break;
		} else {
			int send, recv;

			/* Start setting MAC address */
			for (i = 0; i < 32; i++) {
				struct ether_hdr* hdr =
					rte_pktmbuf_mtod(pkts[i],
						struct ether_hdr*);
				hdr->d_addr.addr_bytes[5] = (10 * q) + 1;
				hdr->s_addr.addr_bytes[5] = (10 * q) + 2;
				hdr->ether_type = rte_cpu_to_be_16(0x0800);
				/*rte_mbuf_sanity_check(pkts[i], 1);*/
			}
			send = send_pkts(PORT_OUT, q, pkts, 32);
			for (i = send; i < 32; i++) {
				mbuf_free(pkts[i]);
			}
			recv = recv_pkts(PORT_IN, q, pkts, 32);
			rcvd += recv;
			sent += send;
			if (cursec() != start_sec) {
				printf("%d %d rx=%d tx=%d\n", n->core,
						(cursec() - start_sec),
						rcvd,
						sent);
				/*printf("recv_pkt\n");*/
				/*rte_pktmbuf_dump(stdout, pkts[0], 16384);*/
				start_sec = cursec();
				rcvd = 0;
				sent = 0;
			}
			for (int i = 0; i < recv; i++) {
				mbuf_free(pkts[i]);
			}
		}
	}
	printf("Socket ID (%d) is %d. DONE\n", n->core, rte_socket_id());
	return NULL;
}
Exemplo n.º 12
0
int main(int argc, const char **argv)
{
    poller = new PortalPoller();
    EchoIndication *echoIndication = new EchoIndication(IfcNames_EchoIndication, poller);
    DisplayInd *dispIndication = new DisplayInd(IfcNames_DisplayInd, poller);
    // these use the default poller
    SwallowProxy *swallowProxy = new SwallowProxy(IfcNames_Swallow);
    echoRequestProxy = new EchoRequestProxy(IfcNames_EchoRequest);

    poller->portalExec_init();
    init_thread();
    portalExec_start();

#if 0
    printf("Timer tests\n");
    portalTimerInit();
    for (int i = 0; i < 1000; i++) {
      portalTimerStart(0);
      portalTimerCatch(1);
      portalTimerCatch(2);
      portalTimerCatch(3);
      portalTimerCatch(4);
      portalTimerCatch(5);
      portalTimerCatch(6);
      portalTimerCatch(7);
      portalTimerCatch(8);
    }
    portalTimerPrint(1000);
#endif

    int v = 42;
    fprintf(stderr, "Saying %d\n", v);
    call_say(v);
    call_say(v*5);
    call_say(v*17);
    call_say(v*93);
    printf("[%s:%d] run %d loops\n\n", __FUNCTION__, __LINE__, LOOP_COUNT);
    portalTimerInit();
    portalTimerStart(1);
    for (int i = 0; i < LOOP_COUNT; i++)
        call_say2(v, v*3);
uint64_t elapsed = portalTimerLap(1);
    printf("TEST TYPE: "
#ifndef SEPARATE_EVENT_THREAD
       "INLINE"
#elif defined(USE_MUTEX_SYNC)
       "MUTEX"
#else
       "SEM"
#endif
       "\n");
    portalTimerPrint(LOOP_COUNT);
    printf("call_say: elapsed %g average %g\n", (double) elapsed, (double) elapsed/ (double) LOOP_COUNT);
    echoRequestProxy->setLeds(9);
    poller->portalExec_end();
    portalExec_end();
    return 0;
}
Exemplo n.º 13
0
/* Creates a new kernel thread named NAME with the given initial
   PRIORITY, which executes FUNCTION passing AUX as the argument,
   and adds it to the ready queue.  Returns the thread identifier
   for the new thread, or TID_ERROR if creation fails.

   If thread_start() has been called, then the new thread may be
   scheduled before thread_create() returns.  It could even exit
   before thread_create() returns.  Contrariwise, the original
   thread may run for any amount of time before the new thread is
   scheduled.  Use a semaphore or some other form of
   synchronization if you need to ensure ordering.

   The code provided sets the new thread's `priority' member to
   PRIORITY, but no actual priority scheduling is implemented.
   Priority scheduling is the goal of Problem 1-3. */
tid_t
thread_create (const char *name, int priority,
               thread_func *function, void *aux) 
{
  struct thread *t;
  struct kernel_thread_frame *kf;
  struct switch_entry_frame *ef;
  struct switch_threads_frame *sf;
  tid_t tid;
  enum intr_level old_level;

  ASSERT (function != NULL);

  /* Allocate thread. */
  t = palloc_get_page (PAL_ZERO);
  if (t == NULL)
    return TID_ERROR;

  /* Initialize thread. */
  init_thread (t, name, priority);
  tid = t->tid = allocate_tid ();

  /* Prepare thread for first run by initializing its stack.
     Do this atomically so intermediate values for the 'stack' 
     member cannot be observed. */
  old_level = intr_disable ();

  /* Stack frame for kernel_thread(). */
  kf = alloc_frame (t, sizeof *kf);
  kf->eip = NULL;
  kf->function = function;
  kf->aux = aux;

  /* Stack frame for switch_entry(). */
  ef = alloc_frame (t, sizeof *ef);
  ef->eip = (void (*) (void)) kernel_thread;

  /* Stack frame for switch_threads(). */
  sf = alloc_frame (t, sizeof *sf);
  sf->eip = switch_entry;
  sf->ebp = 0;

  intr_set_level (old_level);

  /* Add to run queue. */
  thread_unblock (t);

  //we need to call thread yield now to check if this thread
  //has the highest priority
  thread_yield();

  return tid;
}
Exemplo n.º 14
0
int main(void) {
  int c;
  int light=0;
  // set the clocking to run directly from the crystal.
  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                 SYSCTL_XTAL_8MHZ);

  // initialize the OLED display and display "IR Sensor Demo" on the OLED screen.
  RIT128x96x4Init(1000000);

  // enable peripherals
  SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

  // initialize peripherals.
  uart_init();
  led_init();

  // prepare thread table
  init_thread_table();
  init_thread(threadUART);
  init_thread(threadOLED);
  init_thread(threadLED);

  // init systick
  systick_init();

  // register SVC handler
  IntRegister(FAULT_SVCALL, schedule);

  // enable global Interrupts
  IntMasterEnable();

  // kick off this wild ride
  yield();

  exit(0);
}
Exemplo n.º 15
0
Arquivo: init.c Projeto: herumi/kernel
void init_base (struct hal_mmmap *mmmap){

  INFO("Resea " VERSION_STR);

  init_memory(mmmap);
  hal_init();
  init_res();
  add_memory_res();
  init_thread();
  init_msg();

  // start_builtin_servers()
}
Exemplo n.º 16
0
Arquivo: preload.c Projeto: passimm/rr
static void* thread_trampoline(void* arg)
{
	struct thread_func_data* data = arg;
	void* ret;

	init_thread();

	ret = data->start_routine(data->arg);

	/* We don't want glibc re-entering us during thread cleanup. */
	buffer = NULL;
	free(data);
	return ret;
}
Exemplo n.º 17
0
static int __init kthread_init(void)
{
    printk("init thread\n");
    printk("Function name is %s\n", __FUNCTION__);


    if(init_thread())
        goto err;

    return 0;

err:
    clean_thread();
    return -1;
}
Exemplo n.º 18
0
thread_pool_t * 
thread_pool_create(uint32_t thread_count)
{
    thread_pool_t *tp = NULL;
    DIG_CALLOC(tp, 1, sizeof(thread_pool_t));
	if (!tp)
		return NULL;
    DIG_MALLOC(tp->threads, thread_count * sizeof(thread_t));
	int i = 0;
	for (; i < thread_count; ++i)
		init_thread(tp, tp->threads + i);
	tp->thread_count = thread_count;
	pthread_mutex_init(&tp->rb_lock, NULL);
	return tp;
}
Exemplo n.º 19
0
void CXSPThread::InitThread(
		const pthread_mutexattr_t *mutexattr,
		const pthread_condattr_t *condattr,
		const pthread_func func,
		const pthread_cleanup_func cfunc,
		const pthread_once_func ofunc,
		const pthread_key_func kfunc
	)
{
	pthread_func in_func = func ? func:thread_addr;
	pthread_cleanup_func in_cfunc = cfunc ? cfunc:init_clean_func;
	pthread_once_func in_ofunc = ofunc;
	pthread_key_func in_kfunc = kfunc;

	init_thread(&this->m_thread, mutexattr, condattr, in_func, in_cfunc, in_ofunc, in_kfunc);

}
Exemplo n.º 20
0
int		main()
{
  t_philo	philosophes[NB_PHILO];
  int		i;

  i = 0;
  init_mutex_stick();
  init_philo(philosophes);
  init_thread(philosophes);
  while (i < NB_PHILO)
    {
      if (pthread_join(philosophes[i].th_philo, NULL) != 0)
	return (EXIT_FAILURE);
      ++i;
    }
  return (0);
}
Exemplo n.º 21
0
int work_thread_init(size_t size,size_t stack_size){
    int ret=0;
    assert(size!=0 || stack_size!=0);
    STACK_SIZE=stack_size;
    for(int i=0;i<size;i++){
        notify_t *p_notify=p_notify_t+i;
        if(p_notify==NULL){
            ret=-1;
            break;
        }
        if(init_thread(p_notify)==-1){
            ret=-1;
            break;
        }

    }
    return ret;
}
Exemplo n.º 22
0
PUBLIC int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr,
	    "Usage: move [-t] <dbfilename> [<move-source-code-file> ...]\n"
	    "\t-t\tInhibits loading threads which were active when the DB was saved\n");
    exit(MOVE_EXIT_ERROR);
  }

  signal(SIGINT, siginthandler);	/* %%% This can be made to emergency-flush
					   the database to disk, later on %%% */

  write_pid();

  init_gc();
  init_object();
  init_prim();
  init_vm_global();
  init_thread();

  checkpoint_filename = "move.checkpoint";

  install_primitives();

  {
    int load_threads = 1;

    if (!strcmp(argv[1], "-t")) {
      load_threads = 0;
      argv++;
      argc--;
    }

    import_db(argv[1], load_threads);
  }

  bind_primitives_to_symbols();

  import_cmdline_files(argc - 2, argv + 2);

  run_main_loop();

  done_gc();
  return MOVE_EXIT_OK;
}
Exemplo n.º 23
0
void init_boe(int argc, char* argv[]) {
	init_directories(argv[0]);
	init_menubar(); // Do this first of all because otherwise a default File and Window menu will be seen
	sync_prefs();
	init_graph_tool();
	init_snd_tool();
	
	cDialog::init();
	init_sbar(text_sbar, sbar_rect, 58, 11, 58);
	init_sbar(item_sbar, item_sbar_rect, 16, 8);
	init_sbar(shop_sbar, shop_sbar_rect, 16, 8);
	init_btn(done_btn, BTN_DONE);
	init_btn(help_btn, BTN_HELP);
	
	adjust_window_mode();
	// If we don't do this now it'll flash white to start with
	mainPtr.clear(sf::Color::Black);
	mainPtr.display();
	
	make_cursor_watch();
	boost::thread init_thread([]() {
		init_buf();
		check_for_intel();
		srand(time(nullptr));
		init_screen_locs();
		Set_up_win();
		init_startup();
		flushingInput = true;
	});
	show_logo();
	if(get_bool_pref("ShowStartupSplash", true))
		plop_fancy_startup();
	init_thread.join();
	
	cUniverse::print_result = iLiving::print_result = add_string_to_buf;
	cPlayer::give_help = give_help;
	set_up_apple_events(argc, argv);
	init_fileio();
	init_spell_menus();
	init_mini_map();
	redraw_screen(REFRESH_NONE);
	showMenuBar();
}
car_timestamp_sender::car_timestamp_sender() {
	wsa_init = false;
	if (!init_wsa()) {
		throw exception("init wsa failed\n");
	}
	
	if (!init_socket()) {
		cleanup_wsa();
		throw exception("init socket failed\n");
	}

	if (!init_thread()) {
		cleanup_socket();
		cleanup_wsa();
		throw exception("init thread failed\n");
	}

	timeBeginPeriod(1);
}
Exemplo n.º 25
0
int main (void) {

    board_init();
	#ifdef SIMULATE
	init_socket();
	#endif

    printf("JoyOS v"JOYOS_VERSION"\n");

	#ifndef SIMULATE
    init_thread();
    create_thread(&robot_monitor, STACK_DEFAULT, 0, "main");
    rf_init();
    schedule();
	#else 
	robot_monitor();
	#endif

}
Exemplo n.º 26
0
int main(int argc, char** argv) 
{
  init_queue();
  int i; 
  long long sum, *arr;


  printf("Usage: %s numelements numthreads\n", argv[0]);
  if (argc > 3) {
    abort();
  }
  if (argc > 2)  numelems   = atoi(argv[1]);
  if (argc == 3) numthreads = atoi(argv[2]);
  // ----------------------------------------

  arr = (long long*)malloc(sizeof(long long) * (numthreads/2));

  local_block_t *q = init_thread();
  printf("Q created and initialized: %p\n",q);

  printf("Starting %d producers and consumers, each will pass %d elements.\n", numthreads/2, numelems);
  for (i=0; i<numthreads/2; i++) 
    cilk_spawn producer(q);

  for (i=0; i<numthreads/2; i++) 
    arr[i] = cilk_spawn consumer(q);

  cilk_sync;
  printf("All producers and consumers finished.\n");

  sum = 0;
  for (i=0; i<numthreads/2; i++) 
    sum += arr[i];

  printf("Total: %ld\n", sum);

  // Default parameters should result in: 1999998000000
  if ( numelems == 1000000 && numthreads == 8 && sum != 1999998000000) {
    printf("ERROR: ANSWER NOT CORRECT, EXPECTING %ld\n", 1999998000000);
    fflush(stdout);
    abort();
  }
}
Exemplo n.º 27
0
static int setup_kinect(int index, int fmt, int is_depth)
{
	pending_runloop_tasks_inc();
	pthread_mutex_lock(&runloop_lock);
	int thread_running_prev = thread_running;
	if (!thread_running)
		init_thread();
	if (!kinects[index]) {
		kinects[index] = alloc_kinect(index);
	}
	if (!kinects[index]) {
		printf("Error: Invalid index [%d]\n", index);
		// If we started the thread, we need to bring it back
		if (!thread_running_prev) {
			thread_running = 0;
			pthread_mutex_unlock(&runloop_lock);
			pending_runloop_tasks_dec();
			pthread_join(thread, NULL);
		} else {
			pthread_mutex_unlock(&runloop_lock);
			pending_runloop_tasks_dec();
		}
		return -1;
	}
	freenect_set_user(kinects[index]->dev, kinects[index]);
	buffer_ring_t *buf;
	if (is_depth)
		buf = &kinects[index]->depth;
	else
		buf = &kinects[index]->video;
	pthread_mutex_lock(&buf->lock);
	if (buf->fmt != fmt) {
		if (is_depth)
			change_depth_format(kinects[index], (freenect_depth_format)fmt);
		else
			change_video_format(kinects[index], (freenect_video_format)fmt);
	}
	pthread_mutex_unlock(&buf->lock);
	pthread_mutex_unlock(&runloop_lock);
	pending_runloop_tasks_dec();
	return 0;
}
Exemplo n.º 28
0
static int __init kthread_init(void)
{
	printk("init thread\n");
	printk("Function name is %s\n",__FUNCTION__);

#ifndef STATIC_INIT_THREAD
	create_threadlock();
#else 
	printk("static init threadlock\n");
#endif
	
	if(init_thread())
		goto err;

	return 0;
	
err:
	clean_thread();
	return -1;
}
Exemplo n.º 29
0
void kernel_threads_init()
{
    uint8_t tid;

    tid = init_thread("Idle",
                      THREAD_PRIO_IDLE,
                      idle_thread_entry,
                      NULL,
                      1 * KBYTE);

    if ((THREAD_TID_INVALID == tid) || (THREAD_TID_IDLE != tid)) {
        kernel_panic("cannot create the IDLE thread.");
        return;
    }

    if (!scheduler_add_thread(tid)) {
        kernel_panic("cannot add IDLE to the scheduler.");
    }

    kprintf("kernel threads setup complete.\n");
}
Exemplo n.º 30
0
int __used parasite_service(unsigned int cmd, void *args)
{
	pr_info("Parasite cmd %d/%x process\n", cmd, cmd);

	switch (cmd) {
	case PARASITE_CMD_INIT:
		return init(args);
	case PARASITE_CMD_INIT_THREAD:
		return init_thread();
	case PARASITE_CMD_FINI:
		return fini();
	case PARASITE_CMD_FINI_THREAD:
		return fini_thread();
	case PARASITE_CMD_CFG_LOG:
		return parasite_cfg_log(args);
	case PARASITE_CMD_DUMPPAGES:
		return dump_pages(args);
	case PARASITE_CMD_MPROTECT_VMAS:
		return mprotect_vmas(args);
	case PARASITE_CMD_DUMP_SIGACTS:
		return dump_sigact(args);
	case PARASITE_CMD_DUMP_ITIMERS:
		return dump_itimers(args);
	case PARASITE_CMD_DUMP_MISC:
		return dump_misc(args);
	case PARASITE_CMD_DUMP_CREDS:
		return dump_creds(args);
	case PARASITE_CMD_DUMP_THREAD:
		return dump_thread(args);
	case PARASITE_CMD_DRAIN_FDS:
		return drain_fds(args);
	case PARASITE_CMD_GET_PROC_FD:
		return parasite_get_proc_fd();
	case PARASITE_CMD_DUMP_TTY:
		return parasite_dump_tty(args);
	}

	pr_err("Unknown command to parasite: %d\n", cmd);
	return -EINVAL;
}