From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] Broken Fedora build
Date: Thu, 22 Oct 2020 14:27:13 +0800 [thread overview]
Message-ID: <5F912641.9090004@cn.fujitsu.com> (raw)
In-Reply-To: <5F91252F.3040504@cn.fujitsu.com>
On 2020/10/22 14:22, Yang Xu wrote:
> Hi Li
>> Xiao Yang<yangx.jy@cn.fujitsu.com> wrote:
>>
>>>>> I prefer to go replace ftime() by gettimeofday() or clock_gettime()
>>>>> way to solve this from root.
>>>> +1
>>>>
>>>> I have seen the hugetlb.c and trace_sched.c code, they all use the
>>>> time to generate a random value for ftok or sched_priority. So using
>>>> gettimeofday() also looks ok.
>>> Hi,
>>>
>>> It is fine for me to replace ftime(), but I wonder if we can remove
>>> fime() and srand()/srandom() directly? :-)
>>> It seems unnecessary to set the seed for random number.
>>
>> That's true, but random() will generate the same number each time.
> Agree. If we don't call srandom, repeatly call random binary will give
> same random num. ie
> root@localhost ~]# ./random
> random num 1804289383
> random num 846930886
> random num 1681692777
> random num 1714636915
> random num 1957747793
> random num 424238335
> random num 719885386
> random num 1649760492
> random num 596516649
> random num 1189641421
> [root@localhost ~]# ./random
> random num 1804289383
> random num 846930886
> random num 1681692777
> random num 1714636915
> random num 1957747793
> random num 424238335
> random num 719885386
> random num 1649760492
> random num 596516649
> random num 1189641421
> [root@localhost ~]# cat random.c
> #include <stdlib.h>
> #include <stdio.h>
>
> void main(void)
> {
> int num,i;
> for (i=0;i<10;i++) {
> num =random();
> printf("random num %d\n", num);
> }
> }
> [root@localhost ~]#
>
> So keep this maybe better.
Hi Li, Yang
Thanks for your replies. It's reasonable for me to keep it. :-)
Best Regards,
Xiao Yang
>
> Best Regards
> Yang Xu
>> I slightly tend to keep setting the seed by srandom() to get a different
>> randomized number for test variety.
>>
>
> .
>
next prev parent reply other threads:[~2020-10-22 6:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 19:35 [LTP] Broken Fedora build Petr Vorel
2020-10-22 2:36 ` Li Wang
2020-10-22 2:44 ` Yang Xu
2020-10-22 5:18 ` Xiao Yang
2020-10-22 5:47 ` Li Wang
2020-10-22 6:22 ` Yang Xu
2020-10-22 6:27 ` Xiao Yang [this message]
2020-10-22 6:01 ` Jan Stancek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5F912641.9090004@cn.fujitsu.com \
--to=yangx.jy@cn.fujitsu.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox