コード例 #1
0
ファイル: pthread.c プロジェクト: bkolobara/Benu-pi
/*!
 * Create new thread (params on user stack!)
 * \param thread User level thread descriptor
 * \param attr Thread attributes
 * \param start_routine Starting function for new thread
 * \param arg Parameter sent to starting function
 * (parameters are on calling thread stack)
 */
int sys__pthread_create ( pthread_t *thread, pthread_attr_t *attr,
			  void *(*start_routine) (void *), void *arg )
{
	kthread_t *kthread;
	uint flags = 0;
	int sched_policy = SCHED_FIFO;
	int sched_priority = THREAD_DEF_PRIO;
	void *stackaddr = NULL;
	size_t stacksize = 0;

	SYS_ENTRY();

	if ( attr )
	{
		flags = attr->flags;
		sched_policy = attr->sched_policy;
		sched_priority = attr->sched_params.sched_priority;
		stackaddr = attr->stackaddr;
		stacksize = attr->stacksize;

		ASSERT_ERRNO_AND_EXIT ( sched_policy == SCHED_FIFO,
					ENOTSUP );
		ASSERT_ERRNO_AND_EXIT (
			sched_priority >= THREAD_MIN_PRIO &&
			sched_priority <= THREAD_MAX_PRIO,
			ENOMEM
		);

		/* if ( flags & SOMETHING ) change attributes ... */
	}

	kthread = kthread_create ( start_routine, arg, flags,
				   sched_policy, sched_priority,
				   stackaddr, stacksize );

	ASSERT_ERRNO_AND_EXIT ( kthread, ENOMEM );

	if ( thread )
	{
		thread->ptr = kthread;
		thread->id = kthread_get_id (kthread);
	}

	kthreads_schedule ();

	SYS_EXIT ( EXIT_SUCCESS, EXIT_SUCCESS );
}
コード例 #2
0
int
vcons_init(struct vcons_data *vd, void *cookie, struct wsscreen_descr *def,
    struct wsdisplay_accessops *ao)
{

	/* zero out everything so we can rely on untouched fields being 0 */
	memset(vd, 0, sizeof(struct vcons_data));
	
	vd->cookie = cookie;

	vd->init_screen = vcons_dummy_init_screen;
	vd->show_screen_cb = NULL;

	/* keep a copy of the accessops that we replace below with our
	 * own wrappers */
	vd->ioctl = ao->ioctl;

	/* configure the accessops */
	ao->ioctl = vcons_ioctl;
	ao->alloc_screen = vcons_alloc_screen;
	ao->free_screen = vcons_free_screen;
	ao->show_screen = vcons_show_screen;
#ifdef WSDISPLAY_SCROLLSUPPORT
	ao->scroll = vcons_scroll;
#endif

	LIST_INIT(&vd->screens);
	vd->active = NULL;
	vd->wanted = NULL;
	vd->currenttype = def;
	callout_init(&vd->switch_callout, 0);
	callout_setfunc(&vd->switch_callout, vcons_do_switch, vd);

	/*
	 * a lock to serialize access to the framebuffer.
	 * when switching screens we need to make sure there's no rasops
	 * operation in progress
	 */
#ifdef DIAGNOSTIC
	vd->switch_poll_count = 0;
#endif
#ifdef VCONS_SWITCH_ASYNC
	kthread_create(PRI_NONE, 0, NULL, vcons_kthread, vd,
	    &vd->redraw_thread, "vcons_draw");
#endif
	return 0;
}
コード例 #3
0
void create_dma_threads()
{
	struct task_struct *p[MAX_THREADS];
	int t_count;

	for (t_count = 0; t_count < MAX_THREADS; t_count++) {
		p[t_count] = kthread_create(dma_chain_thread_entry, &cht[t_count],
								"dma_chain_thread");
		kthread_bind(p[t_count], t_count);
	}

	/* Start all the threads at a time */
	for (t_count = 0; t_count < MAX_THREADS; t_count++) {
		wake_up_process(p[t_count]);
	}
	return;
}
コード例 #4
0
ファイル: vfs_sync.c プロジェクト: mihaicarabas/dragonfly
/*
 * Create per-filesystem syncer process
 */
void
vn_syncer_thr_create(struct mount *mp)
{
	struct syncer_ctx *ctx;
	static int syncalloc = 0;

	ctx = kmalloc(sizeof(struct syncer_ctx), M_TEMP, M_WAITOK | M_ZERO);
	ctx->sc_mp = mp;
	ctx->sc_flags = 0;
	ctx->syncer_workitem_pending = hashinit(SYNCER_MAXDELAY, M_DEVBUF,
						&ctx->syncer_mask);
	ctx->syncer_delayno = 0;
	lwkt_token_init(&ctx->sc_token, "syncer");
	mp->mnt_syncer_ctx = ctx;
	kthread_create(syncer_thread, ctx, &ctx->sc_thread,
		       "syncer%d", ++syncalloc & 0x7FFFFFFF);
}
コード例 #5
0
static int AVL6211_Blindscan_Scan(struct dvb_frontend* fe, struct dvbsx_blindscanpara *pbspara)
{
	printk(KERN_INFO "AVL6211_Blindscan_Scan printk\n");

	AVL_DVBSx_IBSP_WaitSemaphore(&blindscanSem);
	fe_use = fe;
	blindstart=1;
	AVL_DVBSx_IBSP_ReleaseSemaphore(&blindscanSem);
	  dvbs2_task = kthread_create(dvbs2_blindscan_task, pbspara, "dvbs2_task");
      if(!dvbs2_task){
      	printk("Unable to start dvbs2 thread.\n");
     	dvbs2_task = NULL;
      return -1;
      }
	  wake_up_process(dvbs2_task);
	  return 0;
}
コード例 #6
0
ファイル: dm_cpu_hotplug.c プロジェクト: gundal/nobleltehk
static int exynos_dm_hotplug_notifier(struct notifier_block *notifier,
					unsigned long pm_event, void *v)
{
	switch (pm_event) {
	case PM_SUSPEND_PREPARE:
		mutex_lock(&thread_lock);
		in_suspend_prepared = true;
		if(nr_sleep_prepare_cpus > 1) {
			pr_info("%s, %d : dynamic_hotplug CMD_SLEEP_PREPARE\n", __func__, __LINE__);
			if (!dynamic_hotplug(CMD_SLEEP_PREPARE))
				prev_cmd = CMD_LOW_POWER;
		}
		else {
			if (!dynamic_hotplug(CMD_LOW_POWER))
				prev_cmd = CMD_LOW_POWER;
		}
		exynos_dm_hotplug_disable();
		if (dm_hotplug_task) {
			kthread_stop(dm_hotplug_task);
			dm_hotplug_task = NULL;
		}
		mutex_unlock(&thread_lock);
		break;

	case PM_POST_SUSPEND:
		mutex_lock(&thread_lock);
		exynos_dm_hotplug_enable();

		dm_hotplug_task =
			kthread_create(on_run, NULL, "thread_hotplug");
		if (IS_ERR(dm_hotplug_task)) {
			mutex_unlock(&thread_lock);
			pr_err("Failed in creation of thread.\n");
			return -EINVAL;
		}

		in_suspend_prepared = false;

		wake_up_process(dm_hotplug_task);
		mutex_unlock(&thread_lock);
		break;
	}

	return NOTIFY_OK;
}
コード例 #7
0
ファイル: ddump_mt.c プロジェクト: jamescth/notes
static void ddump_percpu_thread_create(void)
{
//	struct task_struct *ddump_thread_helper;
	int	index = 0, order = 1;
	int	cpu = 0;	// need to figure out how to bind CPU
	struct task_struct *tmp_thread;

	for (; index < HELPERS ; index++, cpu++, order++) {

		// if we have used all cpus, stop
		if (cpu == ddump_nr_cpus) {
			break;
		}

		// we don't want to assign any helper to the current cpu
		if (cpu == ddump_current_cpu) {
			cpu++;
		}

		tmp_thread = kthread_create(ddump_percpu_thread,
					    (void *)(long)index,
					    "ddump_helper/%d",
					    cpu);

		printk("James kthread %p\n", tmp_thread);

		ddump_thread_helper[index].cp_thread = tmp_thread;
		ddump_thread_helper[index].cp_order = order;

		// bind thread to the cpu
		if (likely(!IS_ERR(ddump_thread_helper[index].cp_thread))) {
			ddump_thread_helper[index].cp_cpu = cpu;

			//kthread_bind(tmp_thread, cpu);
		} else {
		// cant create thread
		// in real case, do single thread
			panic("CANT create ddump helper\n");
		}

		wake_up_process(tmp_thread);
	}

	max_helpers = index;
}
コード例 #8
0
ファイル: kmain.c プロジェクト: dan-boa/kernel2
/**
 * This function, called by the idle process (within 'idleproc_run'), creates the
 * process commonly refered to as the "init" process, which should have PID 1.
 *
 * The init process should contain a thread which begins execution in
 * initproc_run().
 *
 * @return a pointer to a newly created thread which will execute
 * initproc_run when it begins executing
 */
static kthread_t *
initproc_create(void)
{
      	
	proc_t *process1=proc_create("Init_process");
 	KASSERT(process1!=NULL);
	dbg(DBG_INIT,"(GRADING1 1.b)  Init Process created successfully\n" );
	kthread_t *thread1=kthread_create(process1,initproc_run,1,(void*)1);
	
	KASSERT(PID_INIT == process1->p_pid);
	dbg(DBG_INIT,"(GRADING1 1.b)  Init process's pid assigned properly\n");
        KASSERT(thread1 != NULL);
	dbg(DBG_INIT,"(GRADING1 1.b)  Init process's thread created successfully\n");
/*	dbg(DBG_INIT,"thread1_returned");*/
	

	return thread1;
}
コード例 #9
0
ファイル: kmain.c プロジェクト: meganesu/OS-HW2
/**
 * This function is called from kmain, however it is not running in a
 * thread context yet. It should create the idle process which will
 * start executing idleproc_run() in a real thread context.  To start
 * executing in the new process's context call context_make_active(),
 * passing in the appropriate context. This function should _NOT_
 * return.
 *
 * Note: Don't forget to set curproc and curthr appropriately.
 *
 * @param arg1 the first argument (unused)
 * @param arg2 the second argument (unused)
 */
static void *
bootstrap(int arg1, void *arg2)
{
        /* necessary to finalize page table information */
        pt_template_init();

        /* Create idle process and idle thread */
        curproc = proc_create("idle");
        curthr = kthread_create(curproc, (kthread_func_t) idleproc_run, NULL, NULL);
        dbg_print("Created idle proc and thread\n");
        /* Make idle thread the active context */
        context_make_active(&curthr->kt_ctx);

        /* NOT_YET_IMPLEMENTED("PROCS: bootstrap"); */

        panic("weenix returned to bootstrap()!!! BAD!!!\n");
        return NULL;
}
コード例 #10
0
static void htckovsky_oj_start_polling(void) {
	struct task_struct *nthread;
	
	mutex_lock(&htckovsky_oj.lock);
	if (htckovsky_oj.task) {
		goto done;
	}

	nthread = kthread_create(htckovsky_oj_thread, NULL, "oj_thread");
	if (!nthread) {
		pr_err(MODULE_NAME": failed to start OJ refresh thread\n");
		goto done;
	}
	wake_up_process(nthread);
	htckovsky_oj.task = nthread;
done:
	mutex_unlock(&htckovsky_oj.lock);
}
コード例 #11
0
ファイル: kmain.c プロジェクト: jiangchhz/abmp
/**
 * This function is called from kmain, however it is not running in a
 * thread context yet. It should create the idle process which will
 * start executing idleproc_run() in a real thread context.  To start
 * executing in the new process's context call context_make_active(),
 * passing in the appropriate context. This function should _NOT_
 * return.
 *
 * Note: Don't forget to set curproc and curthr appropriately.
 *
 * @param arg1 the first argument (unused)
 * @param arg2 the second argument (unused)
 */
static void *bootstrap(int arg1, void *arg2)
{
        /* necessary to finalize page table information */
        pt_template_init();
        char name[]="IDLE";                 
        curproc=proc_create(name);
       KASSERT(curproc != NULL && "Could not create Idle process"); /* make sure that the "idle" process has been created successfully */
        KASSERT(curproc->p_pid == PID_IDLE);
        KASSERT(PID_IDLE == curproc->p_pid && "Process created is not Idle");        
      
        curthr=kthread_create(curproc,idleproc_run,arg1,arg2);
        KASSERT(curthr != NULL && "Could not create thread for Idle process");      

        context_make_active(&(curthr->kt_ctx));
        NOT_YET_IMPLEMENTED("PROCS: bootstrap");
        panic("weenix returned to bootstrap()!!! BAD!!!\n");
        return NULL;
}
コード例 #12
0
/* begin: add by wufan w00163571 for use kernel thread kick watchdog 20121201 */
static int k3_wdt_kick_start_oncpu(int cpu)
{
	int err = 0;
	struct task_struct *p = per_cpu(k3wdt_kick_watchdog_task, cpu);
	if (!p) {
		p = kthread_create(k3wdt_kick_threadfunc, (void *)(unsigned long)cpu, "k3wdt_kicktask/%d", cpu);
		if (IS_ERR(p)) {
			printk(KERN_ERR "softlockup watchdog for %i failed\n", cpu);
			err = PTR_ERR(p);
			goto out;
		}
		kthread_bind(p, cpu);
		per_cpu(k3wdt_kick_watchdog_task, cpu) = p;
		wake_up_process(p);
	}
out:
	return err;
}
コード例 #13
0
int ep952_thread_enable(void)
{
	int err;

    if(ep952_task)
        return 0;

    ep952_task = kthread_create(ep952_thread, NULL, "ep952_task");
    if(IS_ERR(ep952_task)){
        printk("Unable to start kernel thread./n");
        err = PTR_ERR(ep952_task);
        ep952_task = NULL;
        return err;
    } else {
        wake_up_process(ep952_task);
    }
	return 0;
}
コード例 #14
0
ファイル: uisthread.c プロジェクト: 383530895/linux
/* returns 0 for failure, 1 for success */
int
uisthread_start(struct uisthread_info *thrinfo,
		int (*threadfn)(void *), void *thrcontext, char *name)
{
	thrinfo->should_stop = 0;
	/* used to stop the thread */
	init_completion(&thrinfo->has_stopped);
	thrinfo->task = kthread_create(threadfn, thrcontext, name, NULL);
	if (IS_ERR(thrinfo->task)) {
		thrinfo->id = 0;
		return 0;	/* failure */
	}
	thrinfo->id = thrinfo->task->pid;
	wake_up_process(thrinfo->task);
	LOGINF("started thread pid:%d\n", thrinfo->id);
	return 1;

}
コード例 #15
0
ファイル: vcvideobuf.c プロジェクト: jsebechlebsky/vcdev
int vc_start_streaming( struct vb2_queue * q, unsigned int count )
{
    struct vc_device * dev;
    PRINT_DEBUG( "start streaming vb called, count = %d\n", count);

    dev = q->drv_priv;

    //Try to start kernel thread
    dev->sub_thr_id = kthread_create( submitter_thread, dev, "vcam_submitter");
    if( !dev->sub_thr_id ){
        PRINT_ERROR("Failed to create kernel thread\n");
        return -ECANCELED;
    }

    wake_up_process(dev->sub_thr_id);

    return 0;
}
コード例 #16
0
ファイル: thread-1.c プロジェクト: deveshnagar/device-drivers
static int __init init_thread(void)
{
	printk(KERN_INFO "thread-1: Creating Thread\n");
	thread_st = kthread_create(thread_fn, NULL, "thread-1");
	if (thread_st)
	{
		/*
		 * Thread created and not in running state.
		 * Call wake_up_process to run it.
		 */
		printk(KERN_INFO "thread-1: Thread Created successfully\n");
	}
	else
	{
		printk(KERN_ERR "thread-1: Thread creation failed\n");
	}
	return 0;
}
コード例 #17
0
VCOS_STATUS_T vcos_thread_create(VCOS_THREAD_T *thread,
                                 const char *name,
                                 VCOS_THREAD_ATTR_T *attrs,
                                 VCOS_THREAD_ENTRY_FN_T entry,
                                 void *arg)
{
   VCOS_STATUS_T st;
   struct task_struct *kthread;

   memset(thread, 0, sizeof(*thread));
   thread->magic     = VCOS_THREAD_MAGIC;
   strlcpy( thread->name, name, sizeof( thread->name ));
   thread->legacy    = attrs ? attrs->legacy : 0;
   thread->entry = entry;
   thread->arg = arg;

   if (!name)
   {
      vcos_assert(0);
      return VCOS_EINVAL;
   }

   st = vcos_semaphore_create(&thread->wait, NULL, 0);
   if (st != VCOS_SUCCESS)
   {
      return st;
   }

   st = vcos_semaphore_create(&thread->suspend, NULL, 0);
   if (st != VCOS_SUCCESS)
   {
      return st;
   }

   /*required for event groups */
   vcos_timer_create(&thread->_timer.timer, thread->name, NULL, NULL);

   kthread = kthread_create((int (*)(void *))vcos_thread_wrapper, (void*)thread, name);
   vcos_assert(kthread != NULL);
   set_user_nice(kthread, attrs->ta_priority);
   thread->thread.thread = kthread;
   wake_up_process(kthread);
   return VCOS_SUCCESS;
}
コード例 #18
0
ファイル: kern_task.c プロジェクト: orumin/openbsd-efivars
void
taskq_create_thread(void *arg)
{
    struct taskq *tq = arg;
    int rv;

    mtx_enter(&tq->tq_mtx);

    switch (tq->tq_state) {
    case TQ_S_DESTROYED:
        mtx_leave(&tq->tq_mtx);
        free(tq, M_DEVBUF, sizeof(*tq));
        return;

    case TQ_S_CREATED:
        tq->tq_state = TQ_S_RUNNING;
        break;

    default:
        panic("unexpected %s tq state %d", tq->tq_name, tq->tq_state);
    }

    do {
        tq->tq_running++;
        mtx_leave(&tq->tq_mtx);

        rv = kthread_create(taskq_thread, tq, NULL, tq->tq_name);

        mtx_enter(&tq->tq_mtx);
        if (rv != 0) {
            printf("unable to create thread for \"%s\" taskq\n",
                   tq->tq_name);

            tq->tq_running--;
            /* could have been destroyed during kthread_create */
            if (tq->tq_state == TQ_S_DESTROYED &&
                    tq->tq_running == 0)
                wakeup_one(&tq->tq_running);
            break;
        }
    } while (tq->tq_running < tq->tq_nthreads);

    mtx_leave(&tq->tq_mtx);
}
コード例 #19
0
ファイル: bomber.c プロジェクト: chixsh/tempesta
static int __init
tfw_bmb_init(void)
{
	long i;
	volatile unsigned long ts_start;
	struct task_struct *task;
	int r = 0;

	if (tfw_addr_pton(&TFW_STR_FROM(server), &bmb_server_address)) {
		TFW_ERR("Unable to parse server's address: %s", server);
		return -EINVAL;
	}
	TFW_LOG("Started bomber module, server's address is %s\n", server);

	if (tfw_bmb_alloc())
		return -ENOMEM;

	ts_start = jiffies;

	for (i = 0; i < nthreads; i++) {
		task = kthread_create(tfw_bmb_worker, (void *)i, "worker");
		if (IS_ERR_OR_NULL(task)) {
			TFW_ERR("Unable to create worker\n");
			r = -EINVAL;
			goto stop_threads;
		}
		bmb_task[i].task_struct = task;
	}

	atomic_set(&bmb_threads, nthreads);
	for (i = 0; i < nthreads; i++)
		wake_up_process(bmb_task[i].task_struct);

	wait_event_interruptible(bmb_task_wq, !atomic_read(&bmb_threads));

	tfw_bmb_report(ts_start);

stop_threads:
	tfw_bmb_stop_threads();
	tfw_bmb_free();

	return r;
}
コード例 #20
0
ファイル: thread.c プロジェクト: bkolobara/Benu-pi
/*! initialize thread structures and create idle thread */
void kthreads_init ()
{
	list_init ( &all_threads );
	list_init ( &procs );

	active_thread = NULL;
	ksched_init ();

	/* initially create 'idle thread' */
	kernel_proc.prog = NULL;
	kernel_proc.stack_pool = NULL; /* use kernel pool */
	kernel_proc.m.start = NULL;
	kernel_proc.m.size = (size_t) 0xffffffff;

	(void) kthread_create ( idle_thread, NULL, 0, SCHED_FIFO, 0, NULL,
				NULL, 0, &kernel_proc );

	kthreads_schedule ();
}
コード例 #21
0
ファイル: kmain.c プロジェクト: BarFox/gitDir
    int do_faber(kshell_t *kshell, int argc, char **argv)
    {

        /*
         * Shouldn't call a test function directly.
         * It's best to invoke it in a separate kernel process.  
         */
        
        proc_t *new_proc;
        kthread_t *new_thr;
        new_proc = proc_create("new");

        new_thr = kthread_create(new_proc, faber_thread_test, 0, NULL);
        sched_make_runnable(new_thr);
        int status; 
        pid_t child = do_waitpid(-1, 0, &status);

        return 0;
    }
コード例 #22
0
int disp_init_irq(void)
{
    static char * device_name="mtk_disp";

    if(irq_init)
        return 0;

    irq_init = 1;
	DDPMSG("disp_init_irq\n");
 
    //create irq log thread
    init_waitqueue_head(&disp_irq_log_wq);
    disp_irq_log_task = kthread_create(disp_irq_log_kthread_func, NULL, "ddp_irq_log_kthread");
	if (IS_ERR(disp_irq_log_task)) {
        DDPERR(" can not create disp_irq_log_task kthread\n");
    }
    //wake_up_process(disp_irq_log_task);
    return 0;
}
コード例 #23
0
int hang_detect_init(void) {

	struct task_struct *hd_thread ;
	//struct proc_dir_entry *de = create_proc_entry(HD_PROC, 0664, 0);
	
	unsigned char *name = "hang_detect" ;
	
	printk("[Hang_Detect] Initialize proc\n");
	
	//de->read_proc = hd_proc_cmd_read;
	//de->write_proc = hd_proc_cmd_write;

	printk("[Hang_Detect] create hang_detect thread\n");

	hd_thread = kthread_create(hang_detect_thread, NULL, name);
	wake_up_process(hd_thread);    

	return 0 ;
}
コード例 #24
0
ファイル: kernel_thread.c プロジェクト: jtestard/cse221
void inline GetElapsedTime(void) {
    int i;
	void* data = NULL;
    for (i = 0; i < ITERATIONS; i++) {
	    // Data required for thread creation.
		static struct task_struct *thread;
	    char our_thread[8]="thread";
		struct timespec ts_start;
		getnstimeofday(&ts_start);
		data = &ts_start;
		printk(KERN_CRIT "Thread create\n");
        thread = kthread_create(thread_fn,data,our_thread);
        if(thread) {
            wake_up_process(thread);
        }
 		kthread_stop(thread);
    }
    return;
}
コード例 #25
0
DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
{
    int rc;
    struct proc *pProc;

#if __FreeBSD_version >= 800002
    rc = kproc_create(rtThreadNativeMain, pThreadInt, &pProc, RFHIGHPID, 0, "%s", pThreadInt->szName);
#else
    rc = kthread_create(rtThreadNativeMain, pThreadInt, &pProc, RFHIGHPID, 0, "%s", pThreadInt->szName);
#endif
    if (!rc)
    {
        *pNativeThread = (RTNATIVETHREAD)FIRST_THREAD_IN_PROC(pProc);
        rc = VINF_SUCCESS;
    }
    else
        rc = RTErrConvertFromErrno(rc);
    return rc;
}
コード例 #26
0
static int start_kicker(void)
{

	int i;
	wk_cpu_update_bit_flag(0, 1);
	for (i = 0; i < CPU_NR; i++) {
		wk_tsk[i] = kthread_create(kwdt_thread, (void *)(unsigned long)i, "wdtk-%d", i);
		if (IS_ERR(wk_tsk[i])) {
			int ret = PTR_ERR(wk_tsk[i]);
			wk_tsk[i] = NULL;
			return ret;
		}
		/* wk_cpu_update_bit_flag(i,1); */
		wk_start_kick_cpu(i);
	}
	g_kicker_init = 1;
	printk("[WDK] WDT start kicker  done\n");
	return 0;
}
コード例 #27
0
ファイル: vm_zeroidle.c プロジェクト: HariKishan8/Networks
static void
pagezero_start(void __unused *arg)
{
	int error;

	error = kthread_create(vm_pagezero, NULL, &pagezero_proc, RFSTOPPED, 0,
	    "pagezero");
	if (error)
		panic("pagezero_start: error %d\n", error);
	/*
	 * We're an idle task, don't count us in the load.
	 */
	PROC_LOCK(pagezero_proc);
	pagezero_proc->p_flag |= P_NOLOAD;
	PROC_UNLOCK(pagezero_proc);
	mtx_lock_spin(&sched_lock);
	setrunqueue(FIRST_THREAD_IN_PROC(pagezero_proc), SRQ_BORING);
	mtx_unlock_spin(&sched_lock);
}
コード例 #28
0
ファイル: blockdev.c プロジェクト: Dennisbonke/DB-OS
int blockdev_register(struct inode *node, struct blockctl *ctl)
{
	struct blockdev *bd = kmalloc(sizeof(struct blockdev));
	mutex_create(&ctl->cachelock, 0);
	hash_create(&ctl->cache, 0, 0x4000);
	mpscq_create(&ctl->queue, 1000);
	bd->ctl = ctl;

	int num = atomic_fetch_add(&next_minor, 1);
	node->devdata = bd;
	node->phys_dev = GETDEV(block_major, num);
	node->kdev = dm_device_get(block_major);
	
	kthread_create(&ctl->elevator, "[kelevator]", 0, block_elevator_main, node);
	char name[64];
	snprintf(name, 64, "/dev/bcache-%d", num);
	kerfs_register_parameter(name, ctl, 0, 0, kerfs_block_cache_report);
	return num;
}
コード例 #29
0
ファイル: tsleep.c プロジェクト: 2asoft/freebsd
void
rumptest_tsleep()
{
	struct lwp *notbigl[NTHREADS];
	int rv, i;

	mutex_init(&mymtx, MUTEX_DEFAULT, IPL_NONE);

	for (i = 0; i < NTHREADS; i++) {
		rv = kthread_create(PRI_NONE, KTHREAD_MUSTJOIN| KTHREAD_MPSAFE,
		    NULL, tinythread, (void *)(uintptr_t)i, &notbigl[i], "nb");
		if (rv)
			panic("thread create failed: %d", rv);
	}

	for (i = 0; i < NTHREADS; i++) {
		kthread_join(notbigl[i]);
	}
}
コード例 #30
0
static int completion_load(void)
{
	pr_info("%s\n", __func__);

	my_thread = kthread_create(kthread_func, NULL, "%s",
							"udemy kthread");
	if (IS_ERR(my_thread)) {
		pr_info("%s: cannot create kernel thread\n", __func__);
		return PTR_ERR(my_thread);
	}

	/* Protect my_thread from being freed by the kernel */
	get_task_struct(my_thread);

	/* Kick the thread */
	wake_up_process(my_thread);

	return 0;
}