本文整理汇总了C++中FIRST_THREAD_IN_PROC函数的典型用法代码示例。如果您正苦于以下问题:C++ FIRST_THREAD_IN_PROC函数的具体用法?C++ FIRST_THREAD_IN_PROC怎么用?C++ FIRST_THREAD_IN_PROC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FIRST_THREAD_IN_PROC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kproc_kthread_add
int
kproc_kthread_add(void (*func)(void *), void *arg,
struct proc **procptr, struct thread **tdptr,
int flags, int pages, const char *procname, const char *fmt, ...)
{
int error;
va_list ap;
char buf[100];
struct thread *td;
if (*procptr == 0) {
error = kproc_create(func, arg,
procptr, flags, pages, "%s", procname);
if (error)
return (error);
td = FIRST_THREAD_IN_PROC(*procptr);
if (tdptr)
*tdptr = td;
va_start(ap, fmt);
vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap);
va_end(ap);
#ifdef KTR
sched_clear_tdname(td);
#endif
return (0);
}
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
error = kthread_add(func, arg, *procptr,
tdptr, flags, pages, "%s", buf);
return (error);
}
示例2: linux_fork
int
linux_fork(struct thread *td, struct linux_fork_args *args)
{
struct fork_req fr;
int error;
struct proc *p2;
struct thread *td2;
#ifdef DEBUG
if (ldebug(fork))
printf(ARGS(fork, ""));
#endif
bzero(&fr, sizeof(fr));
fr.fr_flags = RFFDG | RFPROC | RFSTOPPED;
fr.fr_procp = &p2;
if ((error = fork1(td, &fr)) != 0)
return (error);
td2 = FIRST_THREAD_IN_PROC(p2);
linux_proc_init(td, td2, 0);
td->td_retval[0] = p2->p_pid;
/*
* Make this runnable after we are finished with it.
*/
thread_lock(td2);
TD_SET_CAN_RUN(td2);
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
return (0);
}
示例3: ald_daemon
static void
ald_daemon(void)
{
int needwakeup;
struct alq *alq;
ald_thread = FIRST_THREAD_IN_PROC(ald_proc);
EVENTHANDLER_REGISTER(shutdown_pre_sync, ald_shutdown, NULL,
SHUTDOWN_PRI_FIRST);
ALD_LOCK();
for (;;) {
while ((alq = LIST_FIRST(&ald_active)) == NULL)
msleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0);
ALQ_LOCK(alq);
ald_deactivate(alq);
ALD_UNLOCK();
needwakeup = alq_doio(alq);
ALQ_UNLOCK(alq);
if (needwakeup)
wakeup(alq);
ALD_LOCK();
}
}
示例4: exec_linux_imgact_try
static int
exec_linux_imgact_try(struct image_params *imgp)
{
const char *head = (const char *)imgp->image_header;
char *rpath;
int error = -1, len;
/*
* The interpreter for shell scripts run from a linux binary needs
* to be located in /compat/linux if possible in order to recursively
* maintain linux path emulation.
*/
if (((const short *)head)[0] == SHELLMAGIC) {
/*
* Run our normal shell image activator. If it succeeds
* attempt to use the alternate path for the interpreter.
* If an alternate path is found, use our stringspace
* to store it.
*/
if ((error = exec_shell_imgact(imgp)) == 0) {
linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
imgp->interpreter_name, UIO_SYSSPACE,
&rpath, 0, AT_FDCWD);
if (rpath != NULL) {
len = strlen(rpath) + 1;
if (len <= MAXSHELLCMDLEN)
memcpy(imgp->interpreter_name,
rpath, len);
free(rpath, M_TEMP);
}
}
}
return(error);
}
示例5: linux_fork
int
linux_fork(struct thread *td, struct linux_fork_args *args)
{
int error;
struct proc *p2;
struct thread *td2;
#ifdef DEBUG
if (ldebug(fork))
printf(ARGS(fork, ""));
#endif
if ((error = fork1(td, RFFDG | RFPROC | RFSTOPPED, 0, &p2, NULL, 0))
!= 0)
return (error);
td->td_retval[0] = p2->p_pid;
td->td_retval[1] = 0;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
td2 = FIRST_THREAD_IN_PROC(p2);
/*
* Make this runnable after we are finished with it.
*/
thread_lock(td2);
TD_SET_CAN_RUN(td2);
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
return (0);
}
示例6: tesla_perthread_process_dtor
static void
tesla_perthread_process_dtor(__unused void *arg, struct proc *p)
{
struct thread *td;
td = FIRST_THREAD_IN_PROC(p);
if (td != NULL && td->td_tesla != NULL)
tesla_store_reset(td->td_tesla);
}
示例7: procfs_doprocfpregs
int
procfs_doprocfpregs(PFS_FILL_ARGS)
{
int error;
struct fpreg r;
struct thread *td2;
#ifdef COMPAT_FREEBSD32
struct fpreg32 r32;
int wrap32 = 0;
#endif
if (uio->uio_offset != 0)
return (0);
PROC_LOCK(p);
PROC_ASSERT_HELD(p);
if (p_candebug(td, p)) {
PROC_UNLOCK(p);
return (EPERM);
}
if (!P_SHOULDSTOP(p)) {
PROC_UNLOCK(p);
return (EBUSY);
}
td2 = FIRST_THREAD_IN_PROC(p);
#ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32)) {
if (SV_PROC_FLAG(td2->td_proc, SV_ILP32) == 0) {
PROC_UNLOCK(p);
return (EINVAL);
}
wrap32 = 1;
memset(&r32, 0, sizeof(r32));
} else
#endif
memset(&r, 0, sizeof(r));
error = PROC(read, fpregs, td2, &r);
if (error == 0) {
PROC_UNLOCK(p);
error = UIOMOVE_FROMBUF(r, uio);
PROC_LOCK(p);
}
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (!P_SHOULDSTOP(p))
error = EBUSY;
else
/* XXXKSE: */
error = PROC(write, fpregs, td2, &r);
}
PROC_UNLOCK(p);
return (error);
}
示例8: procfs_doprocdbregs
int
procfs_doprocdbregs(PFS_FILL_ARGS)
{
int error;
struct dbreg r;
struct thread *td2;
#ifdef COMPAT_FREEBSD32
struct dbreg32 r32;
int wrap32 = 0;
#endif
if (uio->uio_offset != 0)
return (0);
PROC_LOCK(p);
KASSERT(p->p_lock > 0, ("proc not held"));
if (p_candebug(td, p) != 0) {
PROC_UNLOCK(p);
return (EPERM);
}
td2 = FIRST_THREAD_IN_PROC(p);
#ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32)) {
if (SV_PROC_FLAG(td2->td_proc, SV_ILP32) == 0) {
PROC_UNLOCK(p);
return (EINVAL);
}
wrap32 = 1;
}
#endif
error = PROC(read, dbregs, td2, &r);
if (error == 0) {
PROC_UNLOCK(p);
error = UIOMOVE_FROMBUF(r, uio);
PROC_LOCK(p);
}
if (error == 0 && uio->uio_rw == UIO_WRITE) {
if (!P_SHOULDSTOP(p)) /* XXXKSE should be P_TRACED? */
error = EBUSY;
else
/* XXXKSE: */
error = PROC(write, dbregs, td2, &r);
}
PROC_UNLOCK(p);
return (error);
}
示例9: proc_fini
/*
* UMA should ensure that this function is never called.
* Freeing a proc structure would violate type stability.
*/
static void
proc_fini(void *mem, int size)
{
#ifdef notnow
struct proc *p;
p = (struct proc *)mem;
EVENTHANDLER_INVOKE(process_fini, p);
pstats_free(p->p_stats);
thread_free(FIRST_THREAD_IN_PROC(p));
mtx_destroy(&p->p_mtx);
if (p->p_ksi != NULL)
ksiginfo_free(p->p_ksi);
#else
panic("proc reclaimed");
#endif
}
示例10: linux_vfork
int
linux_vfork(struct thread *td, struct linux_vfork_args *args)
{
int error;
struct proc *p2;
struct thread *td2;
#ifdef DEBUG
if (ldebug(vfork))
printf(ARGS(vfork, ""));
#endif
/* Exclude RFPPWAIT */
if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2,
NULL, 0)) != 0)
return (error);
td->td_retval[0] = p2->p_pid;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
PROC_LOCK(p2);
p2->p_flag |= P_PPWAIT;
PROC_UNLOCK(p2);
td2 = FIRST_THREAD_IN_PROC(p2);
/*
* Make this runnable after we are finished with it.
*/
thread_lock(td2);
TD_SET_CAN_RUN(td2);
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
/* wait for the children to exit, ie. emulate vfork */
PROC_LOCK(p2);
while (p2->p_flag & P_PPWAIT)
cv_wait(&p2->p_pwait, &p2->p_mtx);
PROC_UNLOCK(p2);
return (0);
}
示例11: DECLHIDDEN
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;
}
示例12: pagezero_start
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);
}
示例13: pagezero_start
static void
pagezero_start(void __unused *arg)
{
int error;
struct proc *p;
struct thread *td;
error = kproc_create(vm_pagezero, NULL, &p, RFSTOPPED, 0, "pagezero");
if (error)
panic("pagezero_start: error %d\n", error);
td = FIRST_THREAD_IN_PROC(p);
thread_lock(td);
/* We're an idle task, don't count us in the load. */
td->td_flags |= TDF_NOLOAD;
sched_class(td, PRI_IDLE);
sched_prio(td, PRI_MAX_IDLE);
sched_add(td, SRQ_BORING);
thread_unlock(td);
}
示例14: proc_dtor
/*
* Reclaim a proc after use.
*/
static void
proc_dtor(void *mem, int size, void *arg)
{
struct proc *p;
struct thread *td;
/* INVARIANTS checks go here */
p = (struct proc *)mem;
td = FIRST_THREAD_IN_PROC(p);
SDT_PROBE(proc, kernel, dtor, entry, p, size, arg, td, 0);
if (td != NULL) {
#ifdef INVARIANTS
KASSERT((p->p_numthreads == 1),
("bad number of threads in exiting process"));
KASSERT(STAILQ_EMPTY(&p->p_ktr), ("proc_dtor: non-empty p_ktr"));
#endif
/* Free all OSD associated to this thread. */
osd_thread_exit(td);
}
EVENTHANDLER_INVOKE(process_dtor, p);
if (p->p_ksi != NULL)
KASSERT(! KSI_ONQ(p->p_ksi), ("SIGCHLD queue"));
SDT_PROBE(proc, kernel, dtor, return, p, size, arg, 0, 0);
}
示例15: ald_daemon
static void
ald_daemon(void)
{
int needwakeup;
struct alq *alq;
ald_thread = FIRST_THREAD_IN_PROC(ald_proc);
alq_eventhandler_tag = EVENTHANDLER_REGISTER(shutdown_pre_sync,
ald_shutdown, NULL, SHUTDOWN_PRI_FIRST);
ALD_LOCK();
for (;;) {
while ((alq = BSD_LIST_FIRST(&ald_active)) == NULL &&
!ald_shutingdown)
mtx_sleep(&ald_active, &ald_mtx, PWAIT, "aldslp", 0);
/* Don't shutdown until all active ALQs are flushed. */
if (ald_shutingdown && alq == NULL) {
ALD_UNLOCK();
break;
}
ALQ_LOCK(alq);
ald_deactivate(alq);
ALD_UNLOCK();
needwakeup = alq_doio(alq);
ALQ_UNLOCK(alq);
if (needwakeup)
wakeup_one(alq);
ALD_LOCK();
}
kproc_exit(0);
}