• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pid_task函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: gr_chroot_shmat

int
gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
		const time_t shm_createtime)
{
#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
	struct pid *pid = NULL;
	time_t starttime;

	if (unlikely(!grsec_enable_chroot_shmat))
		return 1;

	if (likely(!proc_is_chrooted(current)))
		return 1;

	read_lock(&tasklist_lock);

	pid = find_vpid(shm_cprid);
	if (pid) {
		struct task_struct *p;
		p = pid_task(pid, PIDTYPE_PID);
		task_lock(p);
		starttime = p->start_time.tv_sec;
		if (unlikely(!have_same_root(current, p) &&
			     time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime))) {
			task_unlock(p);
			read_unlock(&tasklist_lock);
			gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
			return 0;
		}
		task_unlock(p);
	} else {
		pid = find_vpid(shm_lapid);
		if (pid) {
			struct task_struct *p;
			p = pid_task(pid, PIDTYPE_PID);
			task_lock(p);
			if (unlikely(!have_same_root(current, p))) {
				task_unlock(p);
				read_unlock(&tasklist_lock);
				gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
				return 0;
			}
			task_unlock(p);
		}
	}

	read_unlock(&tasklist_lock);
#endif
	return 1;
}
开发者ID:mikeberkelaar,项目名称:grhardened,代码行数:50,代码来源:grsec_chroot.c


示例2: send_signal

int send_signal(int myPid) {
	/* send the signal */
	struct siginfo info;
	int ret;
	struct task_struct *t;
	struct pid *pid_struct;
	pid_t pid;
	memset(&info, 0, sizeof(struct siginfo));
	info.si_signo = SIG_TEST;
	info.si_code = SI_QUEUE;	// this is bit of a trickery: SI_QUEUE is normally used by sigqueue from user space,
					// and kernel space should use SI_KERNEL. But if SI_KERNEL is used the real_time data 
					// is not delivered to the user space signal handler function. 
	info.si_int = 1;  		//real time signals may have 32 bits of data.

	rcu_read_lock();

	pid = myPid; //integer value of pid
	pid_struct = find_get_pid(pid); //function to find the pid_struct
	t = pid_task(pid_struct,PIDTYPE_PID); //find the task_struct
	if(t == NULL){
		printk("no such pid\n");
		rcu_read_unlock();
		return -ENODEV;
	}
	rcu_read_unlock();
	ret = send_sig_info(SIG_TEST, &info, t);    //send the signal
	if (ret < 0) {
		printk("error sending signal\n");
		return ret;
	}
	return 0;
}
开发者ID:willemwouters,项目名称:linux-device-drivers,代码行数:32,代码来源:signal_misc.c


示例3: print_thread_info

static void print_thread_info(int pid)
{
	struct task_struct *ptask;
	struct pid *k;
    struct thread_info *threadinfo = NULL;
    union thread_union *threadunion = NULL;
    /* find tak by pid */
	k = find_vpid(pid);
	ptask = pid_task(k, PIDTYPE_PID);

	printk(KERN_INFO "process   : %s, pid   : %d\n", ptask->comm, ptask->pid);

    /*  ptask->stack point to thread_unuion  */
    threadinfo = get_thread_info(ptask);

    /* union thread_union
     * {
     *     struct thread_info thread_info;
     *     unsigned long stack[THREAD_SIZE/sizeof(long)];
     * };
     */
    threadunion = get_thread_union(threadinfo);

    show_kstack(threadunion);

    //printk(KERN_INFO "task stack            : %p\n", ptask->stack);
}
开发者ID:gatieme,项目名称:LDD-LinuxDeviceDrivers,代码行数:27,代码来源:print_thread_info.c


示例4: handle_get_pid_cap

static int handle_get_pid_cap(struct rpc_desc *desc, void *_msg, size_t size)
{
	struct pid *pid;
	kernel_krg_cap_t cap;
	const struct cred *old_cred;
	int ret;

	pid = krg_handle_remote_syscall_begin(desc, _msg, size,
					      NULL, &old_cred);
	if (IS_ERR(pid)) {
		ret = PTR_ERR(pid);
		goto out;
	}

	ret = krg_get_cap(pid_task(pid, PIDTYPE_PID), &cap);
	if (ret)
		goto out_end;

	ret = rpc_pack_type(desc, cap);
	if (ret)
		goto err_cancel;

out_end:
	krg_handle_remote_syscall_end(pid, old_cred);

out:
	return ret;

err_cancel:
	rpc_cancel(desc);
	goto out_end;
}
开发者ID:jeanparpaillon,项目名称:kerrighed-kernel,代码行数:32,代码来源:capability.c


示例5: send_signal

void send_signal(unsigned long arg){	
	int ret;
	struct siginfo info;
	struct task_struct *t;
	/* send the signal */
	memset(&info, 0, sizeof(struct siginfo));
	info.si_signo = SIG_TEST;
	info.si_code = SI_QUEUE;	// this is bit of a trickery: SI_QUEUE is normally used by sigqueue from user space,
					// and kernel space should use SI_KERNEL. But if SI_KERNEL is used the real_time data 
					// is not delivered to the user space signal handler function. 
	info.si_int = arg;  		//real time signals may have 32 bits of data.

	rcu_read_lock();
//	t = find_task_by_pid_type(PIDTYPE_PID, pid);  //find the task_struct associated with this pid
	t = pid_task(find_pid_ns(user_process_pid, &init_pid_ns), PIDTYPE_PID);	
	if(t == NULL){
		printk(KERN_WARNING "no such pid\n");
		rcu_read_unlock();
		return -ENODEV;
	}
	rcu_read_unlock();
	ret = send_sig_info(SIG_TEST, &info, t);    //send the signal
	if (ret < 0) {
		printk("error sending signal\n");
		return ret;
	}
	return ret;
}
开发者ID:xnvst,项目名称:dev_ker_drv,代码行数:28,代码来源:mc.c


示例6: ged_dvfs_probe_signal

void ged_dvfs_probe_signal(int signo)
{
	static int cache_pid=GED_NO_UM_SERVICE;
	static struct task_struct *t=NULL;
	struct siginfo info;


	info.si_signo = signo;
	info.si_code = SI_QUEUE;
	info.si_int = 1234; 

	if(cache_pid!=g_probe_pid)
	{
		cache_pid = g_probe_pid;
		if(g_probe_pid==GED_NO_UM_SERVICE)
			t = NULL;
		else
			t = pid_task(find_vpid(g_probe_pid), PIDTYPE_PID); 
	}

	if(t!=NULL)
	{
		send_sig_info(signo, &info, t);
		ged_log_buf_print(ghLogBuf_ged_srv, "[GED_K] send signo %d to ged_srv [%d]",signo, g_probe_pid);
	}
	else
	{
		g_probe_pid = GED_NO_UM_SERVICE;
		ged_log_buf_print(ghLogBuf_ged_srv, "[GED_K] ged_srv not running");
	}


}
开发者ID:John677,项目名称:Kernal_k3note,代码行数:33,代码来源:ged_dvfs.c


示例7: intr_handler

static irqreturn_t intr_handler(int irq,void * dev_id)
{
	pid_t pid;
	struct task_struct *p;
	static long interval = 0;

	if(count==0){
		interval=jiffies;
	}
	//count the interval between two irqs
	interval=jiffies-interval;
	printk("The interval between two interrupts is %ld\n",interval);
	interval=jiffies;
	//printk("Interrupt on %s —–%d /n",dev->name,dev->irq);
	count++;
	
	//pid = sys_getpid();
	asm(
		"movl $0x20,%%eax\n\t"
		"int $0x80\n\t"
		:"=a"(pid)
	);
	p = pid_task(find_vpid(pid),PIDTYPE_PID);
	printk("进程%d的状态:state=%ld   prio=%d   policy=%d\n",pid,p->state,p->prio,p->policy);

	return IRQ_NONE;
}
开发者ID:yonglisss,项目名称:linux,代码行数:27,代码来源:intr2.c


示例8: check_ma

static void check_ma(struct quadd_hrt_ctx *hrt_ctx)
{
	pid_t pid;
	struct pid *pid_s;
	struct task_struct *task = NULL;
	struct mm_struct *mm;
	struct quadd_ctx *quadd_ctx = hrt_ctx->quadd_ctx;
	unsigned long vm_size, rss_size;

	pid = quadd_ctx->param.pids[0];

	rcu_read_lock();
	pid_s = find_vpid(pid);
	if (pid_s)
		task = pid_task(pid_s, PIDTYPE_PID);
	rcu_read_unlock();
	if (!task)
		return;

	mm = task->mm;
	if (!mm)
		return;

	vm_size = mm->total_vm;
	rss_size = get_mm_rss(mm);

	if (vm_size != hrt_ctx->vm_size_prev ||
	    rss_size != hrt_ctx->rss_size_prev) {
		make_sample(hrt_ctx, pid, vm_size, rss_size);
		hrt_ctx->vm_size_prev = vm_size;
		hrt_ctx->rss_size_prev = rss_size;
	}
}
开发者ID:Toradex-Apalis-TK1-AndroidTV,项目名称:android_kernel_nvidia_mm,代码行数:33,代码来源:ma.c


示例9: SYSCALL_DEFINE2

SYSCALL_DEFINE2(smunch, pid_t,pid, long, bit_pattern){
//Check if multi threaded
  struct task_struct *p;
  bool ret;
  p = pid_task(find_vpid(pid), PIDTYPE_PID);
  if(!p){
    pr_alert("\nprocess table is null");
    return -1;
  }
  ret = current_is_single_threaded();
  if(ret == false){
    pr_alert("\nError : Multithreaded process, cannot proceed\n");
    return -1;
  }
  
//Check if traced
  if(p->ptrace & PT_PTRACED){
    pr_alert("\nError : Traced process, cannot proceed\n");
    return -1;
  }

//Check if zombie state 
  if(p->exit_state == EXIT_ZOMBIE){
    if((1 << (SIGKILL-1)) & bit_pattern){
      release_task(p);
    }
    return 0;
  }
  else{
    p->pending.signal.sig[0] |= bit_pattern;
    wake_up_process(p);
  }
return 0;
}
开发者ID:smadhiv,项目名称:signals,代码行数:34,代码来源:stoogecalls.c


示例10: notify_user

static void notify_user(struct job *job, int err, int cid)
{
	struct siginfo sinfo;
	struct task_struct *task;

	memset(&sinfo, 0, sizeof(struct siginfo));
	sinfo.si_code = SI_QUEUE; /* important, make si_int available */
	sinfo.si_int = job->id;
	sinfo.si_signo = SIGUSR1;
	sinfo.si_uid = current_uid();
	if (job->state == STATE_SUCCESS)
		sinfo.si_errno = 0;
	else if (job->state == STATE_FAILED)
		sinfo.si_errno = -err; /* make it positive */
	else
		return;

	task = pid_task(find_vpid(job->pid), PIDTYPE_PID);
	if (!task) {
		INFO("Consumer/%d: pid[%d] not found", cid, job->pid);
		return;
	}

	send_sig_info(SIGUSR1, &sinfo, task);
}
开发者ID:jingyang1988,项目名称:Linux-File-process-module,代码行数:25,代码来源:worker.c


示例11: gr_handle_chroot_unix

int
gr_handle_chroot_unix(const pid_t pid)
{
#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
	struct pid *spid = NULL;

	if (unlikely(!grsec_enable_chroot_unix))
		return 1;

	if (likely(!proc_is_chrooted(current)))
		return 1;

	read_lock(&tasklist_lock);

	spid = find_vpid(pid);
	if (spid) {
		struct task_struct *p;
		p = pid_task(spid, PIDTYPE_PID);
		task_lock(p);
		if (unlikely(!have_same_root(current, p))) {
			task_unlock(p);
			read_unlock(&tasklist_lock);
			gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
			return 0;
		}
		task_unlock(p);
	}
	read_unlock(&tasklist_lock);
#endif
	return 1;
}
开发者ID:mikeberkelaar,项目名称:grhardened,代码行数:31,代码来源:grsec_chroot.c


示例12: Moca_InitProcessManagment

int Moca_InitProcessManagment(int id)
{
    // Monitored pids
    struct pid *pid;
    if(!(Moca_tasksMap=Moca_InitHashMap(Moca_tasksHashBits,
            2*(1<<Moca_tasksHashBits), sizeof(struct _moca_task), NULL,
            Moca_TaskInitializer)))
        goto fail;
    rcu_read_lock();
    pid=find_vpid(id);
    if(!pid)
    {
        // Skip internal process
        rcu_read_unlock();
        goto clean;
    }
    Moca_initTask=pid_task(pid, PIDTYPE_PID);
    rcu_read_unlock();
    if(Moca_InitTaskData()!=0)
        goto clean;
    return 0;
clean:
    Moca_FreeMap(Moca_tasksMap);
fail:
    printk(KERN_NOTICE "Moca fail initializing process data \n");
    return 1;

}
开发者ID:chubbymaggie,项目名称:MOCA,代码行数:28,代码来源:moca_tasks.c


示例13: sys_setsid

asmlinkage long sys_setsid(void)
{
	struct task_struct *group_leader = current->group_leader;
	struct pid *sid = task_pid(group_leader);
	pid_t session = pid_vnr(sid);
	int err = -EPERM;

	write_lock_irq(&tasklist_lock);
	/* Fail if I am already a session leader */
	if (group_leader->signal->leader)
		goto out;

	/* Fail if a process group id already exists that equals the
	 * proposed session id.
	 */
	if (pid_task(sid, PIDTYPE_PGID))
		goto out;

	group_leader->signal->leader = 1;
	__set_special_pids(sid);

	spin_lock(&group_leader->sighand->siglock);
	group_leader->signal->tty = NULL;
	spin_unlock(&group_leader->sighand->siglock);

	err = session;
out:
	write_unlock_irq(&tasklist_lock);
	return err;
}
开发者ID:maraz,项目名称:linux-2.6,代码行数:30,代码来源:sys.c


示例14: VOS_SuspendTask

/*****************************************************************************
 Function   : VOS_SuspendTask
 Description: Suspend a task
 Calls      : OSAL_SuspendTask
 Called By  :
 Input      : ulTaskID  --  id of a task
 Output     : none
 Return     : return VOS_OK if success
 Other      : none
 *****************************************************************************/
VOS_UINT32 VOS_SuspendTask( VOS_UINT32 ulTaskID )
{
    struct task_struct    *tsk;
    pid_t                 ulTemp;

    if( ulTaskID >= vos_TaskCtrlBlkNumber )
    {
        return(VOS_ERR);          
    }
   
    ulTemp = vos_TaskCtrlBlk[ulTaskID].ulLinuxThreadId;

    tsk = pid_task(find_vpid(ulTemp), PIDTYPE_PID);

    if ( VOS_NULL_PTR == tsk)
    {
        return(VOS_ERR);
    }

    if ( tsk->pid != ulTemp )
    {
        printk("susupend find task to set pri fail.\r\n");
        return VOS_ERR;
    }
    
    set_task_state(tsk, TASK_UNINTERRUPTIBLE);
    
    if (tsk == current)
    {     
        schedule();
    }
                
    return VOS_OK;
}
开发者ID:rgmabs19357,项目名称:Huawei-,代码行数:44,代码来源:linux_task.c


示例15: VOS_ResumeTask

/*****************************************************************************
 Function   : VOS_ResumeTask
 Description: Resume a task
 Input      : ulTaskID  --  ID of task
 Return     : Return VOS_OK if successd
 *****************************************************************************/
VOS_UINT32 VOS_ResumeTask( VOS_UINT32 ulTaskID )
{
    pid_t                  ulTemp;
    struct task_struct     *tsk;

    if(ulTaskID >= vos_TaskCtrlBlkNumber)
    {
        return(VOS_ERR);           
    }
    
    ulTemp = vos_TaskCtrlBlk[ulTaskID].ulLinuxThreadId;

    tsk = pid_task(find_vpid(ulTemp), PIDTYPE_PID);
          
    if ( VOS_NULL_PTR == tsk)
    {
        return(VOS_ERR); 
    }

    if ( tsk->pid != ulTemp )
    {
        printk("resume find task to set pri fail.\r\n");
        return VOS_ERR;
    }

    /*set_task_state(tsk, TASK_RUNNING);*/

    wake_up_process(tsk);

    return VOS_OK;
}
开发者ID:rgmabs19357,项目名称:Huawei-,代码行数:37,代码来源:linux_task.c


示例16: wait_for_completion_interruptible_init

//Ä£¿éŒÓÔغ¯Êý¶šÒå
static int __init wait_for_completion_interruptible_init(void)
{	
	int result;
	long leavetime;
	wait_queue_t data;
	printk("<0>into wait_for_completion_interruptible_init.\n");				
	result=kernel_thread(my_function,NULL,CLONE_KERNEL);   //ŽŽœšÐÂœø³Ì

       /*»ñÈ¡ÐÂœø³ÌµÄÃèÊö·ûÐÅÏ¢*/
	struct pid * kpid=find_get_pid(result);
	struct task_struct * task=pid_task(kpid,PIDTYPE_PID);
	init_completion(&comple);	  //³õÊŒ»¯completion±äÁ¿
	init_waitqueue_entry(&data,task);    //ÓÃÐÂœø³Ì³õÊŒ»¯µÈŽý¶ÓÁÐÔªËØ
	__add_wait_queue_tail(&(comple.wait),&data);    //œ«ÐÂœø³ÌŒÓÈëµÈŽý¶ÓÁеÄβ²¿
	leavetime=wait_for_completion_interruptible(&comple);   //×èÈûœø³Ì£¬µÈŽýÐÂœø³ÌµÄœáÊø

	/*ÏÔÊŸº¯Êýwait_for_completion_interruptible( )µÄ·µ»Øœá¹û*/
	printk("<0>the result of the wait_for_completion_interruptible is:%ld\n",leavetime);  

 	/*ÏÔÊŸº¯Êýkernel_thread( )µÄ·µ»Øœá¹û*/		
	printk("<0>the result of the kernel_thread is :%d\n",result);
	printk("<0>the current pid is:%d\n",current->pid);  //ÏÔÊŸµ±Ç°œø³ÌµÄPIDÖµ
	printk("<0>out wait_for_completion_interruptible_init.\n");
	return 0;
}
开发者ID:fjrti,项目名称:snippets,代码行数:26,代码来源:wait_for_completion_interruptible.c


示例17: write_pid

static ssize_t write_pid(struct file *file,const char __user *buf,size_t count,loff_t *ppos){
    //Send signal to user Space
    char mybuf[10];
    
    int ret = 0;
    int pid = 0;
    struct siginfo info;
    struct task_struct *t;
    copy_from_user(mybuf,buf,count);
    sscanf(mybuf,"%d",&pid);
    printk("pid = %d\n",pid);

    memset(&info,0,sizeof(struct siginfo));
    info.si_signo = SIG_TEST;
    info.si_code = SI_QUEUE;
    info.si_int = 1234;

    rcu_read_lock();
    //t = find_task_by_pid_type(PIDTYPE_PID, pid);  //find the task_struct associated with this pid
    t = pid_task(find_pid_ns(pid, &init_pid_ns), PIDTYPE_PID);
    if(t == NULL){
        printk(KERN_INFO "no such pid\n");
        rcu_read_unlock();
        return -ENODEV;
    }
    rcu_read_unlock();

    ret = send_sig_info(SIG_TEST,&info, t);

    if(ret<0){
        printk(KERN_INFO "send signal error");
    }
    return count;
}
开发者ID:sliu132,项目名称:CIS-655-Advance-Computer-Architecture,代码行数:34,代码来源:customPageFault.c


示例18: procinfo_ioctl

static long procinfo_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
#endif
{
    procinfo_t info;
    procinfo_arg_t *info_arg;
    struct task_struct *task;
    pid_t pid;

    switch (cmd) {
        case GET_PROCINFO:
            info_arg = (procinfo_arg_t *) arg;
            pid = info_arg->pid;
            if (pid > 0) {
                task = pid_task(find_vpid(pid), PIDTYPE_PID);
            } else if (pid == 0) {
                task = current;
            } else if (pid < 0) {
                task = current->parent;
            }
            if (task == NULL) {
                return -EINVAL;
            }
            info.pid = task->pid;
            info.ppid = task->parent->pid;
            info.start_time = task->start_time;
            info.num_sib = count_list(&task->sibling);
            if (copy_to_user(info_arg->info, &info, sizeof(procinfo_t))) {
                return -EACCES;
            }
            break;
        default:
            return -EINVAL;
    }
    return 0;
}
开发者ID:sevengram,项目名称:os-hw,代码行数:35,代码来源:procinfo.c


示例19: init_waitqueue_entry_init

/*Ä£¿éŒÓÔغ¯Êý¶šÒå*/
static int __init init_waitqueue_entry_init(void)
{	
	//ŸÖ²¿±äÁ¿¶šÒå
	int result;	
	wait_queue_t data;	

	printk("<0>into init_waitqueue_entry_init.\n");
	
	/*ŽŽœš1žöÐÂœø³Ì*/				
	result=kernel_thread(my_function,NULL,CLONE_KERNEL);

	/*»ñÈ¡ÐÂœø³ÌµÄœø³ÌÃèÊö·ûÐÅÏ¢*/
	struct pid * kpid = find_get_pid(result);
	struct task_struct * task = pid_task(kpid,PIDTYPE_PID);
	
	if(data.private==NULL||data.func==NULL)
	{
		printk("<0>the data has not been initialized\n");	
	}	

	 /*ÓÃÐÂœø³Ì³õÊŒ»¯µÈŽý¶ÓÁÐÔªËØ*/
	init_waitqueue_entry(&data,task);
	if(data.private==task && data.func!=NULL)
	{
		printk("<0>the data has been initialized\n");
		printk("<0>the flags of the data is:%d\n",data.flags);
	}	
	else
	{
开发者ID:fjrti,项目名称:snippets,代码行数:30,代码来源:init_waitqueue_entry.c


示例20: SYSCALL_DEFINE1

// Return count of each signal under a process
SYSCALL_DEFINE1(get_sigcounter, int, signumber){
	unsigned long flags;
	struct task_struct *p;
	pid_t pid = current->pid;
	p = pid_task(find_vpid(pid), PIDTYPE_PID);
	lock_task_sighand(p, &flags);
	pr_alert("%d\n", p->sighand->sigcounter[signumber]);
	unlock_task_sighand(p, &flags);
	return(1);
}
开发者ID:smadhiv,项目名称:signals,代码行数:11,代码来源:stoogecalls.c



注:本文中的pid_task函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pid_to_ptid函数代码示例发布时间:2022-05-30
下一篇:
C++ pid_nr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap