/*
 * Get scheduler class and parameters of
 * process whose pid is input argument.
 */
main (argc, argv)
		int 		argc;
		char 		*argv[];
{
		pcparms_t			pcparms;
		rtparms_t			*rtparmsp;
		tsparms_t			*tsparmsp;
		id_t		pid, rtID, tsID;
		id_t		schedinfo();
		short		priority, tsmaxpri, rtmaxpri;
		ulong		secs;
		long		nsecs;
		pcparms.pc_cid = PC_CLNULL;
		rtparmsp = (rtparms_t *) pcparms.pc_clparms;
		tsparmsp = (tsparms_t *) pcparms.pc_clparms;
		if ((pid = atoi(argv[1])) <= 0) {
			perror ("bad pid");
			exit (1);
		}
		* get scheduler properties for this pid */
		if (priocntl(P_PID, pid, PC_GETPARMS, &pcparms) == -1) {
			perror ("GETPARMS failed");
			exit (2);
		}
		/* get class IDs and maximum priorities for TS and RT */
		if ((tsID = schedinfo ("TS", &tsmaxpri)) == -1) {
			perror ("schedinfo failed for TS");
			exit (3);
		}
		if ((rtID = schedinfo ("RT", &rtmaxpri)) == -1) {
			perror ("schedinfo failed for RT");
			exit (4);
		}
	/* print results */
		if (pcparms.pc_cid == rtID) {
			priority = rtparmsp->rt_pri;
			secs = rtparmsp->rt_tqsecs;
			nsecs = rtparmsp->rt_tqnsecs;
			(void) printf ("process %d: RT priority %d\n",
				pid, priority);
			(void) printf ("	time slice %ld secs, %ld nsecs\n",
				secs, nsecs);
		} else if (pcparms.pc_cid == tsID) {
			priority = tsparmsp->ts_upri;
			(void) printf ("process %d: TS priority %d\n",
				pid, priority);
		} else {
			printf ("Unknown scheduler class %d\n",
				pcparms.pc_cid);
			exit (5);
		}
		return (0);
}
