flat assembler
Message board for the users of flat assembler.
Index
> Linux > How to make timer? Goto page Previous 1, 2 |
Author |
|
revolution 28 Mar 2011, 07:37
JohnFound wrote: These threads terminates really fast and the overhead is not so big. Perhaps a queue system would be better? You could dedicate one thread to dispatching from the queue as each timer expires. This also has the advantage of keeping everything in order (some programs rely upon this for correctness). |
|||
28 Mar 2011, 07:37 |
|
JohnFound 28 Mar 2011, 07:46
revolution wrote: Perhaps a queue system would be better? You could dedicate one thread to dispatching from the queue as each timer expires. This also has the advantage of keeping everything in order (some programs rely upon this for correctness). This looks like good solution. Thanks for the idea, I will try it. |
|||
28 Mar 2011, 07:46 |
|
Endre 28 Mar 2011, 09:21
I know that it's not exactly what you need for your homework, but once I wrote this little thread-example with timer (it's gas source not a fasm one).
|
|||
28 Mar 2011, 09:21 |
|
JohnFound 28 Mar 2011, 10:18
Endre: Creating threads is not an issue. Although using rsi/edi for passing arguments to "clone" looks strange - is it x64 related, or some other system API (not Linux)?
Also, as revolution said - I can't assemble it. |
|||
28 Mar 2011, 10:18 |
|
JohnFound 29 Mar 2011, 04:59
It is done! I have working timer system for FreshLib now. It uses one additional thread and uses very little CPU. If someone is interested - the code is in the repository: timers/linux/timer.asm file in FreshLibDev branch.
As a side effect FreshLib have now Linux thread support in the file: system/Linux/process.asm The implementation does not uses queue for the events, but counter in every timer that counts how many times the counter expired. Then the thread checks this counts and calls the callback for every expiration. Thanks for the help. |
|||
29 Mar 2011, 04:59 |
|
JohnFound 04 Apr 2011, 13:19
The most recent news from my battle with the timers.
As it appeared, XLib have some really nasty behavior towards threads. As a result I stuck with timers for many days... The test application crashed again and again with really weird messages (or without them). Using documented XInitThreads and XLockDisplay didn't help at all. After trying my own lock that to guarantee non simultaneous calls of XLib functions and the program became nearly stable, I realized, that the problem is that XLib simply can't distinguish my threads ( created using sys_clone) and doesn't lock at all. It simply counts all threads as one. After I changed ThreadCreate procedure to use pthreads library, all was fixed as in magic. Now the test application works for my computers (Win32 with andLinux and Ubuntu 10.10) really well. Anyway, let's make some tests. Here I am attaching the compiled test program. Please run it on your Linux box and report if there are some problems. The sources are on usual place in the repository. Regards.
|
|||||||||||
04 Apr 2011, 13:19 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.