Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix host: the timer create one ephemeral thread per one ticket #330

Open
laijs opened this issue Feb 15, 2017 · 7 comments
Open

posix host: the timer create one ephemeral thread per one ticket #330

laijs opened this issue Feb 15, 2017 · 7 comments

Comments

@laijs
Copy link

laijs commented Feb 15, 2017

it is waste.
you can observe the ephemeral threads created/exited for every ticket by using make gdb.

.sigev_notify = SIGEV_THREAD,

@thehajime
Copy link
Member

@laijs what do you mean by make gdb ?

one alternative is #250 to use green threads, others would be thread pool-like implementation.

@laijs
Copy link
Author

laijs commented Feb 15, 2017

it is not easy to observe this behavior, make gdb is the best way to observe it in the test.

one ephemeral thread per one ticket is too much, we need to change it to use several threads instead. example: only one dedicated timer thread.

@laijs
Copy link
Author

laijs commented Feb 15, 2017

one alternative is #250 to use green threads, others would be thread pool-like implementation.

it is unrelated, timer_create() will create pthreads. it is not controlled by lkl-kernel.

@thehajime
Copy link
Member

(thanks, I wasn't aware of make gdb in tools/lkl/Makefile)

if I understood correctly, creating/deleting one pthread per one clockevent makes huge overhead of creating pthread, context switches, etc. I thought green threads instead of pthread (including rewriting timer library, #250) helps to address those situations.

a thread pool (also replacing timer API) does the same.

@liuyuan10
Copy link
Member

liuyuan10 commented Feb 16, 2017 via email

@laijs
Copy link
Author

laijs commented Feb 16, 2017

librt uses rt_sigtimedwait() internal to implement the timer, the posix-host subsystem can also use a dedicated thread to use rt_sigtimedwait() and trigger the irq.

@tavip
Copy link
Member

tavip commented Feb 16, 2017

I thought about the dedicated thread approach, but you can only implement it safely (i.e. make sure the signal is coming to the dedicated thread) only in Linux (see SIGEV_THREAD_ID in timer_create) which would make it non-posix.

linhua55 added a commit to linhua55/linux that referenced this issue May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants