Package: manpages-dev
Version: 1.70-1

Hello, manpages-dev maintainers,

I've been trying out sched_setscheduler &co ,
  and found that when i set a new scheduler policy with a new priority,
  then getpriority does not report new priority,
  while sched_getparams does,

I attach a test program that exhibits this behaviour.

have fun !

  Siward
  (home.wanadoo.nl/siward)

/* scheduler.c : experiment with setting a different scheduling policy */

/* compile with : cc -g -W -Wall scheduler.c -o scheduler */

	#include <stdio.h>		 /* printf()			 */
	#include <sched.h>
	#include <errno.h>		 /* errno, for getpriority()	 */
	#include <sys/resource.h>	 /* getpriority()		 */

	int main( void ){
	  int priority	 ;
	  int policy	 ;
	  int ck	 ;
	  struct sched_param ssp ;

	  printf("scheduling policy number %d is SCHED_OTHER\n", SCHED_OTHER );
	  printf("scheduling policy number %d is SCHED_FIFO \n", SCHED_FIFO  );
	  printf("scheduling policy number %d is SCHED_RR   \n", SCHED_RR    );
	  policy = sched_getscheduler(0);
	  printf("initial policy is %d\n", policy );
	  if( policy < 0 ){ return(0); }
	  errno = 0 ; priority = getpriority( PRIO_PROCESS, 0 );
	  if( errno != 0 ){ printf("failed getpriority()\n"); return(0); }
	  printf("initial priority is %d\n", priority );
	  printf("max priority for SCHED_OTHER is %d\n", sched_get_priority_max(SCHED_OTHER) );
	  printf("min priority for SCHED_OTHER is %d\n", sched_get_priority_min(SCHED_OTHER) );
	  printf("max priority for SCHED_FIFO  is %d\n", sched_get_priority_max(SCHED_FIFO ) );
	  printf("min priority for SCHED_FIFO  is %d\n", sched_get_priority_min(SCHED_FIFO ) );
	  printf("max priority for SCHED_RR    is %d\n", sched_get_priority_max(SCHED_RR   ) );
	  printf("min priority for SCHED_RR    is %d\n", sched_get_priority_min(SCHED_RR   ) );
	  ssp.sched_priority = 1 ;
	  ck = sched_setscheduler( 0, SCHED_FIFO, &ssp );
	  policy = sched_getscheduler(0);
	  printf("new policy is %d\n", policy );
	  if( policy < 0 ){ return(0); }
	  errno = 0 ; priority = getpriority( PRIO_PROCESS, 0 );
	  if( errno != 0 ){ printf("failed getpriority()\n"); return(0); }
	  printf("according to getpriority(), new priority is %d\n", priority );
	  ssp.sched_priority = 0 ;
	  ck = sched_getparam( 0, &ssp );
	  if( ck != 0 ){ printf("sched_getparam() failed\n"); return(0); }
	  printf("according to sched_getparam(), new priority is %d\n", ssp.sched_priority );
	  return(0);
	  }
	

Reply via email to