POSIX-RT-Scheduler

 view release on metacpan or  search on metacpan

lib/POSIX/RT/Scheduler.xs  view on Meta::CPAN

	CODE:
		real_policy = get_policy(policy);
		param.sched_priority = arg;
#ifdef THREAD_SCHED
		if (SvOK(pid) && SvROK(pid) && sv_derived_from(pid, "threads"))
			ret = pthread_setschedparam(*get_pthread(pid), real_policy, &param);
		else
#endif
			ret = sched_setscheduler(SvIV(pid), real_policy, &param);
		if (ret == -1)
			die_sys("Could not set scheduler: %s");
	else if (SvROK(pid))
	if (ret == -1) 
		die_sys("Couldn't set scheduler: %s");
	RETVAL = 
#ifdef linux
		(ret == 0) ? sv_2mortal(newSVpvs("0 but true")) : 
#endif
		get_name(ret);
	OUTPUT:
		RETVAL

IV
sched_getpriority(pid)
	int pid;
	PREINIT:
		struct sched_param param;
	CODE:
		{
			sched_getparam(pid, &param);
			RETVAL = param.sched_priority;
		}
	OUTPUT:
		RETVAL

void
sched_setpriority(pid, priority)
	SV* pid;
	int priority;
	PREINIT:
		int ret;
		struct sched_param param;
	CODE:
		param.sched_priority = priority;
		if (!SvOK(pid))
			Perl_croak(aTHX_ "pid is undefined");
#ifdef THREAD_SCHED
		if (SvROK(pid) && sv_derived_from(pid, "threads"))
			ret = pthread_setschedprio(*get_pthread(pid), priority);
		else
#endif
			ret = sched_setparam(SvIV(pid), &param);
		if (ret == -1) 
			die_sys("Couldn't set scheduler priority: %s");

void
sched_priority_range(policy)
	SV* policy;
	PREINIT:
		int real_policy;
	PPCODE:
	real_policy = get_policy(policy);
	mXPUSHi(sched_get_priority_min(real_policy));
	mXPUSHi(sched_get_priority_max(real_policy));
	PUTBACK;

void
sched_yield()
	CODE:
	sched_yield();



( run in 1.491 second using v1.01-cache-2.11-cpan-5511b514fd6 )