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

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

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

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

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

示例1: mic_fasync

static intmic_fasync(int fd, struct file *filp, int on){	int rc=0;	if ((rc = fasync_helper(fd, filp, on, &mic_data.dd_fasync)) < 0) {		return rc;	}	if (on) {#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0))		rc = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);#else		__f_setown(filp, task_pid(current), PIDTYPE_PID, 0);#endif		filp->private_data = filp;	} else {		filp->private_data = NULL;	}	return rc;}
开发者ID:marcelhuberfoo,项目名称:mpss-modules,代码行数:22,


示例2: is_container_init

int is_container_init(struct task_struct *tsk){	int ret = 0;	struct pid *pid;	rcu_read_lock();	pid = task_pid(tsk);	if (pid != NULL && pid->numbers[pid->level].nr == 1)		ret = 1;	rcu_read_unlock();	return ret;}
开发者ID:Oleg-k,项目名称:Cranium_Kernel,代码行数:13,


示例3: debug_rt_mutex_deadlock

/* * We fill out the fields in the waiter to store the information about * the deadlock. We print when we return. act_waiter can be NULL in * case of a remove waiter operation. */void debug_rt_mutex_deadlock(int detect, struct rt_mutex_waiter *act_waiter,			     struct rt_mutex *lock){	struct task_struct *task;	if (!debug_locks || detect || !act_waiter)		return;	task = rt_mutex_owner(act_waiter->lock);	if (task && task != current) {		act_waiter->deadlock_task_pid = get_pid(task_pid(task));		act_waiter->deadlock_lock = lock;	}}
开发者ID:fread-ink,项目名称:fread-kernel-k4,代码行数:19,


示例4: kperf_on_cpu_internal

voidkperf_on_cpu_internal(thread_t thread, thread_continue_t continuation,                      uintptr_t *starting_fp){	if (kperf_kdebug_cswitch) {		/* trace the new thread's PID for Instruments */		int pid = task_pid(get_threadtask(thread));		BUF_DATA(PERF_TI_CSWITCH, thread_tid(thread), pid);	}	if (kperf_lightweight_pet_active) {		kperf_pet_on_cpu(thread, continuation, starting_fp);	}}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:14,


示例5: debug_rt_mutex_deadlock

/* * We fill out the fields in the waiter to store the information about * the deadlock. We print when we return. act_waiter can be NULL in * case of a remove waiter operation. */void debug_rt_mutex_deadlock(enum rtmutex_chainwalk chwalk,			     struct rt_mutex_waiter *act_waiter,			     struct rt_mutex *lock){	struct task_struct *task;	if (!debug_locks || chwalk == RT_MUTEX_FULL_CHAINWALK || !act_waiter)		return;	task = rt_mutex_owner(act_waiter->lock);	if (task && task != current) {		act_waiter->deadlock_task_pid = get_pid(task_pid(task));		act_waiter->deadlock_lock = lock;	}}
开发者ID:mkrufky,项目名称:linux,代码行数:20,


示例6: backfire_write

static ssize_tbackfire_write(struct file *file, const char *buf, size_t count, loff_t *ppos){	int signo;	struct pid *pid;	if (sscanf(buf, "%d", &signo) >= 1) {		if (signo > 0 && signo < 32) {			pid = get_pid(task_pid(current));			do_gettimeofday(&sendtime);			kill_pid(pid, signo, 1);		} else			printk(KERN_ERR "Invalid signal no. %d/n", signo);	}	return strlen(buf);}
开发者ID:1023xp,项目名称:training,代码行数:16,


示例7: kperf_ipi_handler

voidkperf_ipi_handler(void *param){	struct kperf_context ctx;	struct kperf_timer *timer = param;	assert(timer != NULL);	/* Always cut a tracepoint to show a sample event occurred */	BUF_DATA(PERF_TM_HNDLR | DBG_FUNC_START, 0);	int ncpu = cpu_number();	struct kperf_sample *intbuf = kperf_intr_sample_buffer();	/* On a timer, we can see the "real" current thread */	ctx.cur_thread = current_thread();	ctx.cur_pid = task_pid(get_threadtask(ctx.cur_thread));	/* who fired */	ctx.trigger_type = TRIGGER_TYPE_TIMER;	ctx.trigger_id = (unsigned int)(timer - kperf_timerv);	if (ctx.trigger_id == pet_timer_id && ncpu < machine_info.logical_cpu_max) {		kperf_thread_on_cpus[ncpu] = ctx.cur_thread;	}	/* make sure sampling is on */	unsigned int status = kperf_sampling_status();	if (status == KPERF_SAMPLING_OFF) {		BUF_INFO(PERF_TM_HNDLR | DBG_FUNC_END, SAMPLE_OFF);		return;	} else if (status == KPERF_SAMPLING_SHUTDOWN) {		BUF_INFO(PERF_TM_HNDLR | DBG_FUNC_END, SAMPLE_SHUTDOWN);		return;	}	/* call the action -- kernel-only from interrupt, pend user */	int r = kperf_sample(intbuf, &ctx, timer->actionid, SAMPLE_FLAG_PEND_USER);	/* end tracepoint is informational */	BUF_INFO(PERF_TM_HNDLR | DBG_FUNC_END, r);#if defined(__x86_64__)	(void)atomic_bit_clear(&(timer->pending_cpus), ncpu, __ATOMIC_RELAXED);#endif /* defined(__x86_64__) */}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:47,


示例8: r3964_read

static ssize_t r3964_read(struct tty_struct *tty, struct file *file,			  unsigned char __user * buf, size_t nr){	struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;	struct r3964_client_info *pClient;	struct r3964_message *pMsg;	struct r3964_client_message theMsg;	int count;	TRACE_L("read()");	pClient = findClient(pInfo, task_pid(current));	if (pClient) {		pMsg = remove_msg(pInfo, pClient);		if (pMsg == NULL) {			/* no messages available. */			if (file->f_flags & O_NONBLOCK) {				return -EAGAIN;			}			/* block until there is a message: */			wait_event_interruptible(pInfo->read_wait,					(pMsg = remove_msg(pInfo, pClient)));		}		/* If we still haven't got a message, we must have been signalled */		if (!pMsg)			return -EINTR;		/* deliver msg to client process: */		theMsg.msg_id = pMsg->msg_id;		theMsg.arg = pMsg->arg;		theMsg.error_code = pMsg->error_code;		count = sizeof(struct r3964_client_message);		kfree(pMsg);		TRACE_M("r3964_read - msg kfree %p", pMsg);		if (copy_to_user(buf, &theMsg, count))			return -EFAULT;		TRACE_PS("read - return %d", count);		return count;	}	return -EPERM;}
开发者ID:PennPanda,项目名称:linux-repo,代码行数:46,


示例9: mic_fasync

static intmic_fasync(int fd, struct file *filp, int on){	int rc;	if ((rc = fasync_helper(fd, filp, on, &mic_data.dd_fasync)) < 0) {		return rc;	}	if (on) {		rc = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);		filp->private_data = filp;	} else {		filp->private_data = NULL;	}	return rc;}
开发者ID:pwntoast512,项目名称:mpss-modules-3.4.6,代码行数:18,


示例10: find_task_by_vpid

static struct pid *good_sigevent(sigevent_t * event){	struct task_struct *rtn = current->group_leader;	int sig = event->sigev_signo;	if ((event->sigev_notify & SIGEV_THREAD_ID ) &&		(!(rtn = find_task_by_vpid(event->sigev_notify_thread_id)) ||		 !same_thread_group(rtn, current) ||		 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))		return NULL;	if (((event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) &&	    (sig <= 0 || sig > SIGRTMAX || sig_kernel_only(sig) ||	     sig_kernel_coredump(sig)))		return NULL;	return task_pid(rtn);}
开发者ID:garyvan,项目名称:openwrt-1.6,代码行数:18,


示例11: ulo_ctl_queue

static int ulo_ctl_queue(struct ulo_dev *dev, int qindex,			 union ulo_ctl __user *uarg){	struct ulo_qelem *qelem;	/* this element will be freed by ulo_xfer_{start,end}() */	qelem = kmem_cache_alloc(ulo_cache, GFP_KERNEL);	if (IS_ERR(qelem))		return PTR_ERR(qelem);	if (unlikely(copy_from_user(&qelem->ctl, uarg, sizeof(*uarg)))) {		kmem_cache_free(ulo_cache, qelem);		return -EFAULT;	}	if (qindex == UloQ_READY)		qelem->ctl.ready.pid = task_pid(current);	ulo_append(dev, qindex, qelem);	return 0;}
开发者ID:wosigh,项目名称:patches,代码行数:19,


示例12: ModExit

static void __exit ModExit(void){	if(thread_id){		kill_pid(task_pid(thread_id), SIGTERM, 1);	}		wait_for_completion(&on_exit);	device_destroy(template_class, device_number);	class_destroy(template_class);	printk("trying to unregister 0x%x/n", device_number);		cdev_del( driver_object );	unregister_chrdev_region( device_number, 1 );		printk("exiting/n");	}
开发者ID:michaelknoch,项目名称:systemsoftware,代码行数:19,


示例13: mac_task_get_proc

static struct proc *mac_task_get_proc(struct task *task){	if (task == current_task())		return proc_self();	/*	 * Tasks don't really hold a reference on a proc unless the	 * calling thread belongs to the task in question.	 */	int pid = task_pid(task);	struct proc *p = proc_find(pid);	if (p != NULL) {		if (proc_task(p) == task)			return p;		proc_rele(p);	}	return NULL;}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:20,


示例14: kperf_port_to_pid

intkperf_port_to_pid(mach_port_name_t portname){	task_t task;	int pid;	if (!MACH_PORT_VALID(portname)) {		return -1;	}	task = port_name_to_task(portname);	if (task == TASK_NULL) {		return -1;	}	pid = task_pid(task);	task_deallocate_internal(task);	return pid;}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:22,


示例15: register_alloc_info

void register_alloc_info(int index,u64 uiAllocedMemMap ){	unsigned int id = g3d_bootm[index].file_desc_id;	alloc_info *s_info = alloc_info_head;//	printk("<register_alloc_info index=%d id=0x%x AllocedMemMap=0x%x>/n",index,id,uiAllocedMemMap);	while(s_info!=NULL)	{		if(s_info->file_desc_id == id) break;		s_info = s_info->next;	}		if(s_info)	{		if(s_info->uiAllocedMemMap & uiAllocedMemMap) 				printk("err uiAllocedMemMap/n");		else s_info->uiAllocedMemMap|=uiAllocedMemMap;	}	else	{		s_info = vmalloc(sizeof(alloc_info));			s_info->file_desc_id 	= id;		s_info->pId				= task_pid(current);				s_info->next 			= NULL;		s_info->uiAllocedMemMap	= uiAllocedMemMap;		if(alloc_info_tail)				alloc_info_tail->next = s_info;		else				alloc_info_head = s_info;		alloc_info_tail = s_info;	}#ifdef DEBUG_S3C_G3D	g3d_alloc_info_dump();#endif}
开发者ID:moikop,项目名称:Astrum-Kernel,代码行数:39,


示例16: r3964_poll

/* Called without the kernel lock held - fine */static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,			struct poll_table_struct *wait){	struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;	struct r3964_client_info *pClient;	struct r3964_message *pMsg = NULL;	unsigned long flags;	int result = POLLOUT;	TRACE_L("POLL");	pClient = findClient(pInfo, task_pid(current));	if (pClient) {		poll_wait(file, &pInfo->read_wait, wait);		spin_lock_irqsave(&pInfo->lock, flags);		pMsg = pClient->first_msg;		spin_unlock_irqrestore(&pInfo->lock, flags);		if (pMsg)			result |= POLLIN | POLLRDNORM;	} else {		result = -EINVAL;	}	return result;}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:25,


示例17: r3964_write

static ssize_t r3964_write(struct tty_struct *tty, struct file *file,			   const unsigned char *data, size_t count){	struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;	struct r3964_block_header *pHeader;	struct r3964_client_info *pClient;	unsigned char *new_data;	TRACE_L("write request, %d characters", count);/*  * Verify the pointers  */	if (!pInfo)		return -EIO;/* * Ensure that the caller does not wish to send too much. */	if (count > R3964_MTU) {		if (pInfo->flags & R3964_DEBUG) {			TRACE_L(KERN_WARNING "r3964_write: truncating user "				"packet from %u to mtu %d", count, R3964_MTU);		}		count = R3964_MTU;	}/* * Allocate a buffer for the data and copy it from the buffer with header prepended */	new_data = kmalloc(count + sizeof(struct r3964_block_header),			GFP_KERNEL);	TRACE_M("r3964_write - kmalloc %p", new_data);	if (new_data == NULL) {		if (pInfo->flags & R3964_DEBUG) {			printk(KERN_ERR "r3964_write: no memory/n");		}		return -ENOSPC;	}	pHeader = (struct r3964_block_header *)new_data;	pHeader->data = new_data + sizeof(struct r3964_block_header);	pHeader->length = count;	pHeader->locks = 0;	pHeader->owner = NULL;	pClient = findClient(pInfo, task_pid(current));	if (pClient) {		pHeader->owner = pClient;	}	memcpy(pHeader->data, data, count);	/* We already verified this */	if (pInfo->flags & R3964_DEBUG) {		dump_block(pHeader->data, count);	}/* * Add buffer to transmit-queue: */	add_tx_queue(pInfo, pHeader);	trigger_transmit(pInfo);	return 0;}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:64,


示例18: 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,


示例19: kernel_init

static int __init kernel_init(void * unused){	lock_kernel();	/*	 * init can allocate pages on any node	 */	set_mems_allowed(node_possible_map);#ifdef 	CONFIG_SYS_HAS_CONTROL_CPU	/*	 * init can run on cpu0 only .	 */	set_cpus_allowed_ptr(current, cpumask_of(0));#else	/*	 * init can run on any cpu .	 */	set_cpus_allowed_ptr(current, cpu_all_mask);#endif	/*	 * Tell the world that we're going to be the grim	 * reaper of innocent orphaned children.	 *	 * We don't want people to have to make incorrect	 * assumptions about where in the task array this	 * can be found.	 */	init_pid_ns.child_reaper = current;	cad_pid = task_pid(current);	smp_prepare_cpus(setup_max_cpus);	do_pre_smp_initcalls();	start_boot_trace();	smp_init();	sched_init_smp();#ifdef 	CONFIG_SYS_HAS_CONTROL_CPU	/* HeJianjun modified for bug 148, 	 * we run linux local processes on only cpu0, other cpu's are just for running dapp */	set_cpus_allowed_ptr(current, cpumask_of(0));#endif	do_basic_setup();	/*	 * check if there is an early userspace init.  If yes, let it do all	 * the work	 */	if (!ramdisk_execute_command)		ramdisk_execute_command = "/init";	if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {		ramdisk_execute_command = NULL;		prepare_namespace();	}	/*	 * Ok, we have completed the initial bootup, and	 * we're essentially up and running. Get rid of the	 * initmem segments and start the user-mode stuff..	 */	init_post();	return 0;}
开发者ID:millken,项目名称:zhuxianB30,代码行数:70,


示例20: init

static int init(void * unused){	lock_kernel();	/*	 * init can run on any cpu.	 */	set_cpus_allowed(current, CPU_MASK_ALL);	/*	 * Tell the world that we're going to be the grim	 * reaper of innocent orphaned children.	 *	 * We don't want people to have to make incorrect	 * assumptions about where in the task array this	 * can be found.	 */	child_reaper = current;	cad_pid = task_pid(current);	smp_prepare_cpus(max_cpus);	do_pre_smp_initcalls();	smp_init();	sched_init_smp();	cpuset_init_smp();	/*	 * Do this before initcalls, because some drivers want to access	 * firmware files.	 */	populate_rootfs();	do_basic_setup();	/*	 * check if there is an early userspace init.  If yes, let it do all	 * the work	 */	if (!ramdisk_execute_command)		ramdisk_execute_command = "/init";	if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {		ramdisk_execute_command = NULL;		prepare_namespace();	}	/*	 * Ok, we have completed the initial bootup, and	 * we're essentially up and running. Get rid of the	 * initmem segments and start the user-mode stuff..	 */	free_initmem();	unlock_kernel();	mark_rodata_ro();	system_state = SYSTEM_RUNNING;	numa_default_policy();	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)		printk(KERN_WARNING "Warning: unable to open an initial console./n");	(void) sys_dup(0);	(void) sys_dup(0);	if (ramdisk_execute_command) {		run_init_process(ramdisk_execute_command);		printk(KERN_WARNING "Failed to execute %s/n",				ramdisk_execute_command);	}	/*	 * We try each of these until one succeeds.	 *	 * The Bourne shell can be used instead of init if we are 	 * trying to recover a really broken machine.	 */	if (execute_command) {		run_init_process(execute_command);		printk(KERN_WARNING "Failed to execute %s.  Attempting "					"defaults.../n", execute_command);	}	run_init_process("/sbin/init");	run_init_process("/etc/init");	run_init_process("/bin/init");	run_init_process("/bin/sh");	panic("No init found.  Try passing init= option to kernel.");}
开发者ID:possiblybhavin,项目名称:mx27_drv,代码行数:90,


示例21: ecryptfs_miscdev_write

/** * ecryptfs_miscdev_write - handle write to daemon miscdev handle * @file: File for misc dev handle (ignored) * @buf: Buffer containing user data * @count: Amount of data in @buf * @ppos: Pointer to offset in file (ignored) * * miscdevfs packet format: *  Octet 0: Type *  Octets 1-4: network byte order msg_ctx->counter (0's for non-response) *  Octets 5-N0: Size of struct ecryptfs_message to follow *  Octets N0-N1: struct ecryptfs_message (including data) * * Returns the number of bytes read from @buf */static ssize_tecryptfs_miscdev_write(struct file *file, const char __user *buf,		       size_t count, loff_t *ppos){	__be32 counter_nbo;	u32 seq;	size_t packet_size, packet_size_length, i;	ssize_t sz = 0;	char *data;	int rc;	if (count == 0)		goto out;	data = kmalloc(count, GFP_KERNEL);	if (!data) {		printk(KERN_ERR "%s: Out of memory whilst attempting to "		       "kmalloc([%Zd], GFP_KERNEL)/n", __func__, count);		goto out;	}	rc = copy_from_user(data, buf, count);	if (rc) {		printk(KERN_ERR "%s: copy_from_user returned error [%d]/n",		       __func__, rc);		goto out_free;	}	sz = count;	i = 0;	switch (data[i++]) {	case ECRYPTFS_MSG_RESPONSE:		if (count < (1 + 4 + 1 + sizeof(struct ecryptfs_message))) {			printk(KERN_WARNING "%s: Minimum acceptable packet "			       "size is [%Zd], but amount of data written is "			       "only [%Zd]. Discarding response packet./n",			       __func__,			       (1 + 4 + 1 + sizeof(struct ecryptfs_message)),			       count);			goto out_free;		}		memcpy(&counter_nbo, &data[i], 4);		seq = be32_to_cpu(counter_nbo);		i += 4;		rc = ecryptfs_parse_packet_length(&data[i], &packet_size,						  &packet_size_length);		if (rc) {			printk(KERN_WARNING "%s: Error parsing packet length; "			       "rc = [%d]/n", __func__, rc);			goto out_free;		}		i += packet_size_length;		if ((1 + 4 + packet_size_length + packet_size) != count) {			printk(KERN_WARNING "%s: (1 + packet_size_length([%Zd])"			       " + packet_size([%Zd]))([%Zd]) != "			       "count([%Zd]). Invalid packet format./n",			       __func__, packet_size_length, packet_size,			       (1 + packet_size_length + packet_size), count);			goto out_free;		}		rc = ecryptfs_miscdev_response(&data[i], packet_size,					       current->euid,					       current->nsproxy->user_ns,					       task_pid(current), seq);		if (rc)			printk(KERN_WARNING "%s: Failed to deliver miscdev "			       "response to requesting operation; rc = [%d]/n",			       __func__, rc);		break;	case ECRYPTFS_MSG_HELO:		rc = ecryptfs_miscdev_helo(current->euid,					   current->nsproxy->user_ns,					   task_pid(current));		if (rc) {			printk(KERN_ERR "%s: Error attempting to process "			       "helo from pid [0x%p]; rc = [%d]/n", __func__,			       task_pid(current), rc);			goto out_free;		}		break;	case ECRYPTFS_MSG_QUIT:		rc = ecryptfs_miscdev_quit(current->euid,					   current->nsproxy->user_ns,					   task_pid(current));		if (rc) {			printk(KERN_ERR "%s: Error attempting to process "			       "quit from pid [0x%p]; rc = [%d]/n", __func__,			       task_pid(current), rc);//.........这里部分代码省略.........
开发者ID:maraz,项目名称:linux-2.6,代码行数:101,


示例22: r3964_read

static ssize_t r3964_read(struct tty_struct *tty, struct file *file,			  unsigned char __user * buf, size_t nr){	struct r3964_info *pInfo = tty->disc_data;	struct r3964_client_info *pClient;	struct r3964_message *pMsg;	struct r3964_client_message theMsg;	int ret;	TRACE_L("read()");	/*	 *	Internal serialization of reads.	 */	if (file->f_flags & O_NONBLOCK) {		if (!mutex_trylock(&pInfo->read_lock))			return -EAGAIN;	} else {		if (mutex_lock_interruptible(&pInfo->read_lock))			return -ERESTARTSYS;	}	pClient = findClient(pInfo, task_pid(current));	if (pClient) {		pMsg = remove_msg(pInfo, pClient);		if (pMsg == NULL) {			/* no messages available. */			if (tty_io_nonblock(tty, file)) {				ret = -EAGAIN;				goto unlock;			}			/* block until there is a message: */			wait_event_interruptible(tty->read_wait,					(pMsg = remove_msg(pInfo, pClient)));		}		/* If we still haven't got a message, we must have been signalled */		if (!pMsg) {			ret = -EINTR;			goto unlock;		}		/* deliver msg to client process: */		theMsg.msg_id = pMsg->msg_id;		theMsg.arg = pMsg->arg;		theMsg.error_code = pMsg->error_code;		ret = sizeof(struct r3964_client_message);		kfree(pMsg);		TRACE_M("r3964_read - msg kfree %p", pMsg);		if (copy_to_user(buf, &theMsg, ret)) {			ret = -EFAULT;			goto unlock;		}		TRACE_PS("read - return %d", ret);		goto unlock;	}	ret = -EPERM;unlock:	mutex_unlock(&pInfo->read_lock);	return ret;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:65,


示例23: kernel_init

static int __init kernel_init(void * unused){	/*	 * Wait until kthreadd is all set-up.	 */	wait_for_completion(&kthreadd_done);	lock_kernel();	/*	 * init can allocate pages on any node	 */	set_mems_allowed(node_states[N_HIGH_MEMORY]);	/*	 * init can run on any cpu.	 */	set_cpus_allowed_ptr(current, cpu_all_mask);	/*	 * Tell the world that we're going to be the grim	 * reaper of innocent orphaned children.	 *	 * We don't want people to have to make incorrect	 * assumptions about where in the task array this	 * can be found.	 */	init_pid_ns.child_reaper = current;	cad_pid = task_pid(current);	smp_prepare_cpus(setup_max_cpus);	do_pre_smp_initcalls();	start_boot_trace();	smp_init();	sched_init_smp();	do_basic_setup();	/* Open the /dev/console on the rootfs, this should never fail */	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)		printk(KERN_WARNING "Warning: unable to open an initial console./n");	(void) sys_dup(0);	(void) sys_dup(0);	/*	 * check if there is an early userspace init.  If yes, let it do all	 * the work	 */	if (!ramdisk_execute_command)		ramdisk_execute_command = "/init";	if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {		ramdisk_execute_command = NULL;		prepare_namespace();	}	/*	 * Ok, we have completed the initial bootup, and	 * we're essentially up and running. Get rid of the	 * initmem segments and start the user-mode stuff..	 */	init_post();	return 0;}
开发者ID:badcompany1982,项目名称:android_kernel_zte_V768,代码行数:66,


示例24: fcntl_dirnotify

int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg){	struct dnotify_struct *dn;	struct dnotify_struct *odn;	struct dnotify_struct **prev;	struct inode *inode;	fl_owner_t id = current->files;	struct file *f;	int error = 0;	if ((arg & ~DN_MULTISHOT) == 0) {		dnotify_flush(filp, id);		return 0;	}	if (!dir_notify_enable)		return -EINVAL;	inode = filp->f_path.dentry->d_inode;	if (!S_ISDIR(inode->i_mode))		return -ENOTDIR;	dn = kmem_cache_alloc(dn_cache, GFP_KERNEL);	if (dn == NULL)		return -ENOMEM;	spin_lock(&inode->i_lock);	prev = &inode->i_dnotify;	while ((odn = *prev) != NULL) {		if ((odn->dn_owner == id) && (odn->dn_filp == filp)) {			odn->dn_fd = fd;			odn->dn_mask |= arg;			inode->i_dnotify_mask |= arg & ~DN_MULTISHOT;			goto out_free;		}		prev = &odn->dn_next;	}	rcu_read_lock();	f = fcheck(fd);	rcu_read_unlock();	/* we'd lost the race with close(), sod off silently */	/* note that inode->i_lock prevents reordering problems	 * between accesses to descriptor table and ->i_dnotify */	if (f != filp)		goto out_free;	error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);	if (error)		goto out_free;	dn->dn_mask = arg;	dn->dn_fd = fd;	dn->dn_filp = filp;	dn->dn_owner = id;	inode->i_dnotify_mask |= arg & ~DN_MULTISHOT;	dn->dn_next = inode->i_dnotify;	inode->i_dnotify = dn;	spin_unlock(&inode->i_lock);	return 0;out_free:	spin_unlock(&inode->i_lock);	kmem_cache_free(dn_cache, dn);	return error;}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:62,



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


C++ task_pid_vnr函数代码示例
C++ task_pgrp函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。