FreeBSD/sys/compat/linux/linux_misc.c
/*
 * Get affinity of a process.
 */
Get affinity of a process.
Get affinity of a process .
int
linux_sched_getaffinity(struct thread *td,
    struct linux_sched_getaffinity_args *args)
{
	int error;
	struct thread *tdt;
	struct cpuset_getaffinity_args cga;
#ifdef DEBUG
	if (ldebug(sched_getaffinity))
		printf(ARGS(sched_getaffinity, "%d, %d, *"), args->pid,
		    args->len);
#endif
	if (args->len < sizeof(cpuset_t))
		return (EINVAL);
	tdt = linux_tdfind(td, args->pid, -1);
	if (tdt == NULL)
		return (ESRCH);
	PROC_UNLOCK(tdt->td_proc);
	cga.level = CPU_LEVEL_WHICH;
	cga.which = CPU_WHICH_TID;
	cga.id = tdt->td_tid;
	cga.cpusetsize = sizeof(cpuset_t);
	cga.mask = (cpuset_t *) args->user_mask_ptr;
	if ((error = sys_cpuset_getaffinity(td, &cga)) == 0)
		td->td_retval[0] = sizeof(cpuset_t);
	return (error);
}
int linux_sched_getaffinity ( struct thread * td , struct linux_sched_getaffinity_args * args ) { int error ; struct thread * tdt ; struct cpuset_getaffinity_args cga ; #ifdef DEBUG if ( ldebug ( sched_getaffinity ) ) printf ( ARGS ( sched_getaffinity , " " ) , args -> pid , args -> len ) ; #endif if ( args -> len < sizeof ( cpuset_t ) ) return ( EINVAL ) ; tdt = linux_tdfind ( td , args -> pid , -1 ) ; if ( tdt == NULL ) return ( ESRCH ) ; PROC_UNLOCK ( tdt -> td_proc ) ; cga . level = CPU_LEVEL_WHICH ; cga . which = CPU_WHICH_TID ; cga . id = tdt -> td_tid ; cga . cpusetsize = sizeof ( cpuset_t ) ; cga . mask = ( cpuset_t * ) args -> user_mask_ptr ; if ( ( error = sys_cpuset_getaffinity ( td , & cga ) ) == 0 ) td -> td_retval [ 0 ] = sizeof ( cpuset_t ) ; return ( error ) ; }
Get affinity of a process.
Get affinity of a process .