sched_child_runs_first doesn't work

Rock Lee rockdotlee at gmail.com
Fri Dec 8 08:07:31 EST 2017


I've read the post before, and I've seen a lot of saying
"sched_child_runs_first just not a guarantee of anything". But still,
there should be a moment that child process ran first. From my
experiment, there was no single time that child process ran before
father process. Isn't it interesting ?

On Fri, Dec 8, 2017 at 7:18 PM, YU Bo <tsu.yubo at gmail.com> wrote:
> Hi,
>
> On Fri, Dec 08, 2017 at 11:07:15AM +0800, Rock Lee wrote:
>>
>> Hi,
>>
>> I ran my test code but always got the father process run first, even
>> after setting sched_child_runs_first. Could anyone give me a hint?
>> Here is my test code.
>>
>> #include <stdio.h>
>> #include <unistd.h>
>> #include <sys/time.h>
>>
>> int main(void)
>> {
>>    struct timeval tv;
>>    struct timezone tz;
>>    int err;
>>    pid_t ret = fork();
>>
>>    if (ret == 0) {
>>        err = gettimeofday(&tv, &tz);
>>        if (!err)
>>            printf("child time sec %d, usec %d\n", tv.tv_sec, tv.tv_usec);
>>
>>         printf("this child.\n");
>>    } else if (ret > 1) {
>>        err = gettimeofday(&tv, &tz);
>>
>>        if (!err)
>>            printf("father time sec %d, usec %d\n", tv.tv_sec, tv.tv_usec);
>>        printf("this father.\n");
>>    } else
>>        printf("err!!\n");
>>    return 0;
>> }
>>
>
> Maybe here:
>
> https://stackoverflow.com/questions/17391201/does-proc-sys-kernel-sched-child-runs-first-work
>
> Bo
>
>>
>> --
>> Cheers,
>> Rock
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
Cheers,
Rock



More information about the Kernelnewbies mailing list