您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ task_pid_vnr函数代码示例

51自学网 2021-06-03 08:40:48
  C++
这篇教程C++ task_pid_vnr函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中task_pid_vnr函数的典型用法代码示例。如果您正苦于以下问题:C++ task_pid_vnr函数的具体用法?C++ task_pid_vnr怎么用?C++ task_pid_vnr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了task_pid_vnr函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: irix_core_dump

/* Actual dumper. * * This is a two-pass process; first we find the offsets of the bits, * and then they are actually written out.  If we run out of core limit * we just truncate. */static int irix_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit){	int has_dumped = 0;	mm_segment_t fs;	int segs;	int i;	size_t size;	struct vm_area_struct *vma;	struct elfhdr elf;	off_t offset = 0, dataoff;	int numnote = 3;	struct memelfnote notes[3];	struct elf_prstatus prstatus;	/* NT_PRSTATUS */	elf_fpregset_t fpu;		/* NT_PRFPREG */	struct elf_prpsinfo psinfo;	/* NT_PRPSINFO */	/* Count what's needed to dump, up to the limit of coredump size. */	segs = 0;	size = 0;	for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {		if (maydump(vma))		{			int sz = vma->vm_end-vma->vm_start;			if (size+sz >= limit)				break;			else				size += sz;		}		segs++;	}	pr_debug("irix_core_dump: %d segs taking %d bytes/n", segs, size);	/* Set up header. */	memcpy(elf.e_ident, ELFMAG, SELFMAG);	elf.e_ident[EI_CLASS] = ELFCLASS32;	elf.e_ident[EI_DATA] = ELFDATA2LSB;	elf.e_ident[EI_VERSION] = EV_CURRENT;	elf.e_ident[EI_OSABI] = ELF_OSABI;	memset(elf.e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);	elf.e_type = ET_CORE;	elf.e_machine = ELF_ARCH;	elf.e_version = EV_CURRENT;	elf.e_entry = 0;	elf.e_phoff = sizeof(elf);	elf.e_shoff = 0;	elf.e_flags = 0;	elf.e_ehsize = sizeof(elf);	elf.e_phentsize = sizeof(struct elf_phdr);	elf.e_phnum = segs+1;		/* Include notes. */	elf.e_shentsize = 0;	elf.e_shnum = 0;	elf.e_shstrndx = 0;	fs = get_fs();	set_fs(KERNEL_DS);	has_dumped = 1;	current->flags |= PF_DUMPCORE;	DUMP_WRITE(&elf, sizeof(elf));	offset += sizeof(elf);				/* Elf header. */	offset += (segs+1) * sizeof(struct elf_phdr);	/* Program headers. */	/* Set up the notes in similar form to SVR4 core dumps made	 * with info from their /proc.	 */	memset(&psinfo, 0, sizeof(psinfo));	memset(&prstatus, 0, sizeof(prstatus));	notes[0].name = "CORE";	notes[0].type = NT_PRSTATUS;	notes[0].datasz = sizeof(prstatus);	notes[0].data = &prstatus;	prstatus.pr_info.si_signo = prstatus.pr_cursig = signr;	prstatus.pr_sigpend = current->pending.signal.sig[0];	prstatus.pr_sighold = current->blocked.sig[0];	psinfo.pr_pid = prstatus.pr_pid = task_pid_vnr(current);	psinfo.pr_ppid = prstatus.pr_ppid = task_pid_vnr(current->parent);	psinfo.pr_pgrp = prstatus.pr_pgrp = task_pgrp_vnr(current);	psinfo.pr_sid = prstatus.pr_sid = task_session_vnr(current);	if (thread_group_leader(current)) {		/*		 * This is the record for the group leader.  Add in the		 * cumulative times of previous dead threads.  This total		 * won't include the time of each live thread whose state		 * is included in the core dump.  The final total reported		 * to our parent process when it calls wait4 will include		 * those sums as well as the little bit more time it takes		 * this and each other thread to finish dying after the		 * core dump synchronization phase.		 *///.........这里部分代码省略.........
开发者ID:ForayJones,项目名称:iods,代码行数:101,


示例2: do_fork

/* *  Ok, this is the main fork-routine. * * It copies the process, and if successful kick-starts * it and waits for it to finish using the VM if required. */long do_fork(unsigned long clone_flags,             unsigned long stack_start,             struct pt_regs *regs,             unsigned long stack_size,             int __user *parent_tidptr,             int __user *child_tidptr){    struct task_struct *p;    int trace = 0;    long nr;    /*     * Do some preliminary argument and permissions checking before we     * actually start allocating stuff     */    if (clone_flags & CLONE_NEWUSER) {        if (clone_flags & CLONE_THREAD)            return -EINVAL;        /* hopefully this check will go away when userns support is         * complete         */        if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||                !capable(CAP_SETGID))            return -EPERM;    }    /*     * When called from kernel_thread, don't do user tracing stuff.     */    if (likely(user_mode(regs)))        trace = tracehook_prepare_clone(clone_flags);    p = copy_process(clone_flags, stack_start, regs, stack_size,                     child_tidptr, NULL, trace);    /*     * Do this prior waking up the new thread - the thread pointer     * might get invalid after that point, if the thread exits quickly.     */    if (!IS_ERR(p)) {        struct completion vfork;        trace_sched_process_fork(current, p);        nr = task_pid_vnr(p);        if (clone_flags & CLONE_PARENT_SETTID)            put_user(nr, parent_tidptr);        if (clone_flags & CLONE_VFORK) {            p->vfork_done = &vfork;            init_completion(&vfork);        }        audit_finish_fork(p);        tracehook_report_clone(regs, clone_flags, nr, p);        /*         * We set PF_STARTING at creation in case tracing wants to         * use this to distinguish a fully live task from one that         * hasn't gotten to tracehook_report_clone() yet.  Now we         * clear it and set the child going.         */        p->flags &= ~PF_STARTING;        wake_up_new_task(p);        tracehook_report_clone_complete(trace, regs,                                        clone_flags, nr, p);        if (clone_flags & CLONE_VFORK) {            freezer_do_not_count();            wait_for_completion(&vfork);            freezer_count();            tracehook_report_vfork_done(p, nr);        }    } else {        nr = PTR_ERR(p);    }    return nr;}
开发者ID:roxdragon,项目名称:AIR-Kernel_ICS,代码行数:86,


示例3: sys_setpgid

/* * This needs some heavy checking ... * I just haven't the stomach for it. I also don't fully * understand sessions/pgrp etc. Let somebody who does explain it. * * OK, I think I have the protection semantics right.... this is really * only important on a multi-user system anyway, to make sure one user * can't send a signal to a process owned by another.  -TYT, 12/12/91 * * Auch. Had to add the 'did_exec' flag to conform completely to POSIX. * LBT 04.03.94 */asmlinkage long sys_setpgid(pid_t pid, pid_t pgid){	struct task_struct *p;	struct task_struct *group_leader = current->group_leader;	struct pid *pgrp;	int err;	if (!pid)		pid = task_pid_vnr(group_leader);	if (!pgid)		pgid = pid;	if (pgid < 0)		return -EINVAL;	/* From this point forward we keep holding onto the tasklist lock	 * so that our parent does not change from under us. -DaveM	 */	write_lock_irq(&tasklist_lock);	err = -ESRCH;	p = find_task_by_vpid(pid);	if (!p)		goto out;	err = -EINVAL;	if (!thread_group_leader(p))		goto out;	if (same_thread_group(p->real_parent, group_leader)) {		err = -EPERM;		if (task_session(p) != task_session(group_leader))			goto out;		err = -EACCES;		if (p->did_exec)			goto out;	} else {		err = -ESRCH;		if (p != group_leader)			goto out;	}	err = -EPERM;	if (p->signal->leader)		goto out;	pgrp = task_pid(p);	if (pgid != pid) {		struct task_struct *g;		pgrp = find_vpid(pgid);		g = pid_task(pgrp, PIDTYPE_PGID);		if (!g || task_session(g) != task_session(group_leader))			goto out;	}	err = security_task_setpgid(p, pgid);	if (err)		goto out;	if (task_pgrp(p) != pgrp) {		change_pid(p, PIDTYPE_PGID, pgrp);		set_task_pgrp(p, pid_nr(pgrp));	}	err = 0;out:	/* All paths lead to here, thus we are safe. -DaveM */	write_unlock_irq(&tasklist_lock);	return err;}
开发者ID:maraz,项目名称:linux-2.6,代码行数:82,


示例4: do_fork

/* *  Ok, this is the main fork-routine. * * It copies the process, and if successful kick-starts * it and waits for it to finish using the VM if required. */long do_fork(unsigned long clone_flags,	      unsigned long stack_start,	      struct pt_regs *regs,	      unsigned long stack_size,	      int __user *parent_tidptr,	      int __user *child_tidptr){	struct task_struct *p;	int trace = 0;	long nr;	if (unlikely(current->ptrace)) {		trace = fork_traceflag (clone_flags);		if (trace)			clone_flags |= CLONE_PTRACE;	}	p = copy_process(clone_flags, stack_start, regs, stack_size,			child_tidptr, NULL);	/*	 * Do this prior waking up the new thread - the thread pointer	 * might get invalid after that point, if the thread exits quickly.	 */	if (!IS_ERR(p)) {		struct completion vfork;		/*		 * this is enough to call pid_nr_ns here, but this if		 * improves optimisation of regular fork()		 */		nr = (clone_flags & CLONE_NEWPID) ?			task_pid_nr_ns(p, current->nsproxy->pid_ns) :				task_pid_vnr(p);		if (clone_flags & CLONE_PARENT_SETTID)			put_user(nr, parent_tidptr);		if (clone_flags & CLONE_VFORK) {			p->vfork_done = &vfork;			init_completion(&vfork);		}		if ((p->ptrace & PT_PTRACED) || (clone_flags & CLONE_STOPPED)) {			/*			 * We'll start up with an immediate SIGSTOP.			 */			sigaddset(&p->pending.signal, SIGSTOP);			set_tsk_thread_flag(p, TIF_SIGPENDING);		}		if (!(clone_flags & CLONE_STOPPED))			wake_up_new_task(p, clone_flags);		else			p->state = TASK_STOPPED;		if (unlikely (trace)) {			current->ptrace_message = nr;			ptrace_notify ((trace << 8) | SIGTRAP);		}		if (clone_flags & CLONE_VFORK) {			freezer_do_not_count();			wait_for_completion(&vfork);			freezer_count();			if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE)) {				current->ptrace_message = nr;				ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);			}		}	} else {		nr = PTR_ERR(p);	}	return nr;}
开发者ID:dennisszhou,项目名称:cs-3210-project2,代码行数:80,


示例5: format_corename

/* format_corename will inspect the pattern parameter, and output a * name into corename, which must have space for at least * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. */static int format_corename(struct core_name *cn, struct coredump_params *cprm){	const struct cred *cred = current_cred();	const char *pat_ptr = core_pattern;	int ispipe = (*pat_ptr == '|');	int pid_in_pattern = 0;	int err = 0;	cn->used = 0;	cn->corename = NULL;	if (expand_corename(cn, core_name_size))		return -ENOMEM;	cn->corename[0] = '/0';	if (ispipe)		++pat_ptr;	/* Repeat as long as we have more pattern to process and more output	   space */	while (*pat_ptr) {		if (*pat_ptr != '%') {			err = cn_printf(cn, "%c", *pat_ptr++);		} else {			switch (*++pat_ptr) {			/* single % at the end, drop that */			case 0:				goto out;			/* Double percent, output one percent */			case '%':				err = cn_printf(cn, "%c", '%');				break;			/* pid */			case 'p':				pid_in_pattern = 1;				err = cn_printf(cn, "%d",					      task_tgid_vnr(current));				break;			/* global pid */			case 'P':				err = cn_printf(cn, "%d",					      task_tgid_nr(current));				break;			case 'i':				err = cn_printf(cn, "%d",					      task_pid_vnr(current));				break;			case 'I':				err = cn_printf(cn, "%d",					      task_pid_nr(current));				break;			/* uid */			case 'u':				err = cn_printf(cn, "%u",						from_kuid(&init_user_ns,							  cred->uid));				break;			/* gid */			case 'g':				err = cn_printf(cn, "%u",						from_kgid(&init_user_ns,							  cred->gid));				break;			case 'd':				err = cn_printf(cn, "%d",					__get_dumpable(cprm->mm_flags));				break;			/* signal that caused the coredump */			case 's':				err = cn_printf(cn, "%d",						cprm->siginfo->si_signo);				break;			/* UNIX time of coredump */			case 't': {				struct timeval tv;				do_gettimeofday(&tv);				err = cn_printf(cn, "%lu", tv.tv_sec);				break;			}			/* hostname */			case 'h':				down_read(&uts_sem);				err = cn_esc_printf(cn, "%s",					      utsname()->nodename);				up_read(&uts_sem);				break;			/* executable */			case 'e':				err = cn_esc_printf(cn, "%s", current->comm);				break;			case 'E':				err = cn_print_exe_file(cn);				break;			/* core limit size */			case 'c':				err = cn_printf(cn, "%lu",					      rlimit(RLIMIT_CORE));//.........这里部分代码省略.........
开发者ID:Codefollows,项目名称:ps4-linux,代码行数:101,


示例6: ia64_rt_sigreturn

longia64_rt_sigreturn (struct sigscratch *scr){	extern char ia64_strace_leave_kernel, ia64_leave_kernel;	struct sigcontext __user *sc;	struct siginfo si;	sigset_t set;	long retval;	sc = &((struct sigframe __user *) (scr->pt.r12 + 16))->sc;	/*	 * When we return to the previously executing context, r8 and r10 have already	 * been setup the way we want them.  Indeed, if the signal wasn't delivered while	 * in a system call, we must not touch r8 or r10 as otherwise user-level state	 * could be corrupted.	 */	retval = (long) &ia64_leave_kernel;	if (test_thread_flag(TIF_SYSCALL_TRACE)	    || test_thread_flag(TIF_SYSCALL_AUDIT))		/*		 * strace expects to be notified after sigreturn returns even though the		 * context to which we return may not be in the middle of a syscall.		 * Thus, the return-value that strace displays for sigreturn is		 * meaningless.		 */		retval = (long) &ia64_strace_leave_kernel;	if (!access_ok(VERIFY_READ, sc, sizeof(*sc)))		goto give_sigsegv;	if (GET_SIGSET(&set, &sc->sc_mask))		goto give_sigsegv;	sigdelsetmask(&set, ~_BLOCKABLE);	spin_lock_irq(&current->sighand->siglock);	{		current->blocked = set;		recalc_sigpending();	}	spin_unlock_irq(&current->sighand->siglock);	if (restore_sigcontext(sc, scr))		goto give_sigsegv;#if DEBUG_SIG	printk("SIG return (%s:%d): sp=%lx ip=%lx/n",	       current->comm, current->pid, scr->pt.r12, scr->pt.cr_iip);#endif	/*	 * It is more difficult to avoid calling this function than to	 * call it and ignore errors.	 */	do_sigaltstack(&sc->sc_stack, NULL, scr->pt.r12);	return retval;  give_sigsegv:	si.si_signo = SIGSEGV;	si.si_errno = 0;	si.si_code = SI_KERNEL;	si.si_pid = task_pid_vnr(current);	si.si_uid = current_uid();	si.si_addr = sc;	force_sig_info(SIGSEGV, &si, current);	return retval;}
开发者ID:jiaming77,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:67,


示例7: memory_engine_allocate

int memory_engine_allocate(memory_engine_t *engine, size_t size,								size_t alignment, memory_node_t **node){	int res = 0;	memory_node_t *new_node = NULL;	struct task_struct *grptask = NULL;	shm_debug("memory_engine_allocate start. (%d, %d)/n", size, alignment);	if ((engine == NULL) || (node == NULL))		return -EINVAL;#ifdef SHM_GUARD_BYTES_ENABLE	//add gurad bytes.	if (engine->m_cache_or_noncache == SHM_CACHE){		size += SHM_GUARD_BYTES;	}#endif	down(&(engine->m_mutex));	if (size > engine->m_size_free) {		shm_error("heap has not enough (%u) bytes for (%u) bytes/n", engine->m_size_free, size);		res = -ENOMEM;		goto err_exit;	}	/* Find a free node in heap */	new_node = _FindNode_size(engine, size, alignment);	if (new_node == NULL) {		memory_node_t *pLastNode = NULL;		pLastNode = engine->m_root.m_prev_free;		if (pLastNode)			shm_error("heap has not enough liner memory for (%u) bytes, free blocks:%u(max free block:%u)/n",					size, engine->m_num_freeblock, pLastNode->m_size);		else			shm_error("heap has not enough liner memory, no free blocks!!!/n");		res = -ENOMEM;		goto err_exit;	}	/* Do we have enough memory after the allocation to split it? */	if (MEMNODE_ALIGN_SIZE(new_node) - size > engine->m_threshold)		_Split(engine, new_node, size + new_node->m_offset);/* Adjust the node size. */	else		engine->m_num_freeblock--;	engine->m_num_usedblock++;	/* Remove the node from the free list. */	new_node->m_prev_free->m_next_free = new_node->m_next_free;	new_node->m_next_free->m_prev_free = new_node->m_prev_free;	new_node->m_next_free =	new_node->m_prev_free = NULL;	/* Fill in the information. */	new_node->m_alignment = alignment;	/*record pid/thread name in node info, for debug usage*/	new_node->m_threadid = task_pid_vnr(current);/*(current)->pid;*/	/* [email
C++ task_pt_regs函数代码示例
C++ task_pid函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。