Re: [PATCH] schedutils: don't assume SCHED_BATCH and SCHED_IDLE exist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mike Frysinger a écrit :
> On Monday 27 April 2009 03:07:59 Aurelien Jarno wrote:
>> Mike Frysinger a écrit :
>>> On Wednesday 22 April 2009 03:18:28 Aurelien Jarno wrote:
>>>> On Mon, Apr 20, 2009 at 01:13:28AM -0400, Mike Frysinger wrote:
>>>>> On Sunday 19 April 2009 10:34:10 Aurelien Jarno wrote:
>>>>>> SCHED_FIFO, SCHED_OTHER, SCHED_RR are part of POSIX 1003.1b Process
>>>>>> Scheduling, so it is correct to assume they always exists.
>>>>>>
>>>>>> SCHED_BATCH and SCHED_IDLE are Linux specific, we should not assume
>>>>>> they exists.
>>>>> looks like you add a whole lot of ifdef's for no real gain.  on
>>>>> non-Linux systems, you end up with options that simply dont work.  not
>>>>> a big deal. on the flip side, these ifdef's are pretty invasive and
>>>>> split up code in a pretty bad way.
>>>> Ok, please find a simpler patch below, we only adds the #ifdef to the
>>>> locations where we really need the values of SCHED_BATCH and SCHED_IDLE.
>>> i still dont get it.  why do you need these changes at all ?  looks to me
>>> like the build should work perfectly fine on any system regardless of
>>> SCHED_BATCH or SCHED_IDLE being defined/supported/whatever.
>> If SCHED_BATCH is not a defined value how the following code would work?
>>
>>         case SCHED_BATCH:
>>                 printf("SCHED_BATCH\n");
>>                 break;
> 
> this is weird circular logic.  first, you disable the SCHED_BATCH define and 
> then wonder how it could possibly work without it being defined ?  face, meet 
> palm ...
> 
> -#ifndef SCHED_BATCH
> +#if defined (__linux__) && !defined(SCHED_BATCH)
>  # define SCHED_BATCH 3
>  #endif
> -mike

Defining SCHED_BATCH and SCHED_IDLE to random values (ie the ones found
on Linux systems) is not an option as they may collide with the one of
other systems. For example on GNU/kFreeBSD we have:

| /* Scheduling algorithms.  */
| #define SCHED_FIFO      1
| #define SCHED_OTHER     2
| #define SCHED_RR        3

If you also define SCHED_BATCH to 3, the following code does not build
anymore:

|                case 'b':
|                        policy = SCHED_BATCH;
|                        break;

[...]

|                case 'r':
|                        policy = SCHED_RR;
|                        break;

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@xxxxxxxxxxx                 http://www.aurel32.net

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux