From archie@precisionio.com  Mon Mar 24 15:41:27 2003
Return-Path: <archie@precisionio.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D105237B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Mar 2003 15:41:27 -0800 (PST)
Received: from mailman.precisionio.com (dns.precisionio.net [65.192.41.225])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 45C5943F75
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Mar 2003 15:41:27 -0800 (PST)
	(envelope-from archie@precisionio.com)
Received: from bubba.precisionio.com (bubba.precisionio.com [172.16.0.223])
	by mailman.precisionio.com (8.12.8/8.12.6) with ESMTP id h2OKCRnr032945
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Mar 2003 12:12:27 -0800 (PST)
	(envelope-from archie@precisionio.com)
Received: from bubba.precisionio.com (localhost [127.0.0.1])
	by bubba.precisionio.com (8.12.7/8.12.7) with ESMTP id h2OKCQoX075160
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Mar 2003 12:12:26 -0800 (PST)
	(envelope-from archie@bubba.precisionio.com)
Received: (from archie@localhost)
	by bubba.precisionio.com (8.12.7/8.12.7/Submit) id h2OKCQFX075159;
	Mon, 24 Mar 2003 12:12:26 -0800 (PST)
Message-Id: <200303242012.h2OKCQFX075159@bubba.precisionio.com>
Date: Mon, 24 Mar 2003 12:12:26 -0800 (PST)
From: Archie Cobbs <archie@precisionio.com>
Reply-To: Archie Cobbs <archie@precisionio.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: can't get my own policy from sched_getscheduler()
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50260
>Category:       bin
>Synopsis:       can't get my own policy from sched_getscheduler()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    rwatson
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 24 15:50:11 PST 2003
>Closed-Date:    Tue Mar 25 07:51:47 PST 2003
>Last-Modified:  Tue Mar 25 07:51:47 PST 2003
>Originator:     Archie Cobbs
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
Packet Design
>Environment:
System: FreeBSD bubba.precisionio.com 4.7-STABLE FreeBSD 4.7-STABLE #0: Tue Feb 18 09:50:02 PST 2003 archie@bubba.packetdesign.com:/usr/obj/usr/src/sys/BUBBA i386

	
>Description:

    sched_getscheduler(0) returns EPERM.
    Why can't a process get it's own scheduling policy??

    SUSv2 seems to state explicitly that it should be able to:

    > If a process specified by pid exists and if the calling process has
    > permission, the scheduling policy will be returned for the process
    > whose process ID is equal to pid.
    > 
    > If pid is zero, the scheduling policy will be returned for the
    > calling process.

    Ref: http://www.opengroup.org/onlinepubs/7908799/xsh/sched_getscheduler.html

>How-To-Repeat:

    #include <stdio.h>
    #include <stdlib.h>
    #include <pthread.h>
    #include <sched.h>
    #include <err.h>

    int
    main(int ac, char **av)
    {
	    int policy;
	    int min_prio;
	    int max_prio;

	    if ((policy = sched_getscheduler(0)) == -1)
		    err(1, "sched_getscheduler");
	    printf("policy = %d\n", policy);
	    if ((min_prio = sched_get_priority_min(policy)) == -1)
		    err(1, "sched_get_priority_min");
	    if ((max_prio = sched_get_priority_max(policy)) == -1)
		    err(1, "sched_get_priority_max");
	    printf("max = %d\n", max_prio);
	    printf("min = %d\n", min_prio);
	    return 0;
    }

>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: rwatson 
State-Changed-When: Tue Mar 25 07:47:49 PST 2003 
State-Changed-Why:  
In FreeBSD 5.0, the POSIX4 (1003.1b) scheduler interfaces are fully 
accessible to user applications by virtue of re-working the 
inter-process access control as part of the TrustedBSD work. 

I just committed changes to FreeBSD 4.8 and -STABLE to permit the 
use of sched_getparam() and sched_getscheduler() for non-root 
processes, as well as fixed serious bugs that caused the return 
value to be returned in the wrong process.  This appears to be 
sufficient to get applications such as the JDK up and running, 
although it doesn't completely open up the enhanced scheduler 
interface as backporting the complete inter-process access control 
rewrite is probably not worth the time investment at this point. 
If this doesn't resolve the problems you're experiencing, please 
let me know. 



Responsible-Changed-From-To: freebsd-bugs->rwatson 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Tue Mar 25 07:47:49 PST 2003 
Responsible-Changed-Why:  

I've committed a fix; will take responsibility for any follow-ups. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=50260 
>Unformatted:
