当前位置: 首页>>代码示例>>C++>>正文


C++ pid_task函数代码示例

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


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


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