On 4/2/19 2:35 PM, Konrad, Martin via Core-talk wrote:
> Hi,
> I have a bunch of unit tests for support modules that spawn epicsThreads
> and tear them down after a very short time. I noticed that although I'm
> waiting for the thread to shut down cleanly tests are not reproducible.
> In the attached simple code snipped I sometimes see the thread function
> running:
In situations like this I use an epicsEvent, and trigger it at
the start of run(). The main thread would then wait on this
event to detect actual thread start.
> $ time ./a.out
> myThread::myThread() begin
> myThread::myThread() end
> myThread::~myThread() begin
> myThread::run() begin
> myThread::run() end
> myThread::~myThread() end
>
> real 0m8.044s
> user 0m0.025s
> sys 0m0.024s
>
> However, sometimes the destructor gets called so fast that the thread
> function doesn't run:
>
> $ time ./a.out
> myThread::myThread() begin
> myThread::myThread() end
> myThread::~myThread() begin
> myThread::~myThread() end
>
> real 0m5.041s
> user 0m0.014s
> sys 0m0.031s
>
> I'm wondering if there is a way I can ensure run() always runs. I'm
> wondering if making the constructor wait until run() actually starts
> executing.
>
> Thanks,
>
> Martin
>
- Replies:
- Re: How to ensure epicsThread function is running in short-lived environment? Benjamin Franksen via Core-talk
- References:
- How to ensure epicsThread function is running in short-lived environment? Konrad, Martin via Core-talk
- Navigate by Date:
- Prev:
Re: EPICS 7.0.2.1 release preparation Dirk Zimoch via Core-talk
- Next:
Re: a question on a commit comment Johnson, Andrew N. via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
<2019>
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: How to ensure epicsThread function is running in short-lived environment? Dirk Zimoch via Core-talk
- Next:
Re: How to ensure epicsThread function is running in short-lived environment? Benjamin Franksen via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
<2019>
2020
2021
2022
2023
2024
|