flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 24 Mar 2011, 15:06
Perhaps you should also state what resolution in timing you need. Microsecond delays are very different, and use different techniques, compared to hour delays.
|
|||
![]() |
|
JohnFound 24 Mar 2011, 15:48
From 50ms to several seconds.
|
|||
![]() |
|
pelaillo 24 Mar 2011, 17:53
What about using the following syscalls:
Code: sys_setitimer = 068h sys_getitimer = 069h I'll try to produce a working snippet later at home |
|||
![]() |
|
JohnFound 24 Mar 2011, 18:46
pelaillo wrote: What about using the following syscalls: The thing that stopped me to use setitimer functions is that there is only one timer available, so I have to create special library in order to allow several timers to be used in the program. But when I think now - it looks not so bad idea... |
|||
![]() |
|
Tyler 24 Mar 2011, 19:26
Has that library not already been created? It seems like a necessity, surly someone has done it already.
|
|||
![]() |
|
JohnFound 24 Mar 2011, 20:58
Tyler wrote: Has that library not already been created? It seems like a necessity, surly someone has done it already. There is a C implementation. I don't know about any FASM implementation. So, probably it is good idea to make one for FreshLib. It will be portable of course. |
|||
![]() |
|
vid 24 Mar 2011, 22:12
Same issue as with heap: Linux kernel only offers smallest set needed to implement the library, not the library itself. It is not expected someone would use syscalls instead of "proper" using of glibc.
BTW, why don't you use glibc? It might save you few headaches. |
|||
![]() |
|
JohnFound 24 Mar 2011, 22:45
vid wrote: BTW, why don't you use glibc? It might save you few headaches. I would (maybe) but there are thousands of C libraries and what is the proper one? ![]() Linux is a mess of files, links to files, links to links to files and some objects that look and behave like files, but actually are not.... and all these files are text files! ![]() |
|||
![]() |
|
Tyler 24 Mar 2011, 22:52
libgcc is internal gcc stuff, that it links into your C(or other) code.
But, as for finding which thingy to link to: USE MAN!!! ![]() Code: $man libc LIBC(7) Linux Programmer's Manual LIBC(7) NAME libc - Overview of standard C libraries on Linux DESCRIPTION The term "libc" is commonly used as a shorthand for the "standard C library", a library of standard functions that can be used by all C programs (and sometimes by programs in other languages). Because of some history (see below), use of the term "libc" to refer to the stan dard C library is somewhat ambiguous on Linux. glibc By far the most widely used C library on Linux is the GNU C Library (http://www.gnu.org/software/libc/), often referred to as glibc. This is the C library that is nowadays used in all major Linux distribu tions. It is also the C library whose details are documented in the relevant pages of the man-pages project (primarily in Section 3 of the manual). Documentation of glibc is also available in the glibc manual, available via the command info libc. Release 1.0 of glibc was made in September 1992. (There were earlier 0.x releases.) The next major release of glibc was 2.0, at the beginning of 1997. ---=== The pathname /lib/libc.so.6 (or something similar) is normally a sym bolic link that points to the location of the glibc library ===--- , and exe cuting this pathname will cause glibc to display various information about the version installed on your system. |
|||
![]() |
|
JohnFound 24 Mar 2011, 23:11
libc (or whatever it is called today) does not contains decent timers support.
|
|||
![]() |
|
Tyler 24 Mar 2011, 23:15
Moreover, it contains no timer support. You were the one asking about libc, not me.
![]() |
|||
![]() |
|
vid 24 Mar 2011, 23:24
It should at minimal offer some kind of wrapper over kernel function, doesn't it?
|
|||
![]() |
|
JohnFound 24 Mar 2011, 23:33
There are both getitimer and setitimer functions, they are defined as "weak" symbols. (What that means?)
But why I have to use wrappers if I can use the originals? |
|||
![]() |
|
Tyler 25 Mar 2011, 00:58
vid: POSIX does. libc does not.
John: Try this: http://www.gnu.org/s/libc/manual/html_node/Setting-an-Alarm.html. It's POSIX, which is almost as portable as libc. As for an explanation of weak symbols, try http://en.wikipedia.org/wiki/Weak_symbol. |
|||
![]() |
|
vid 25 Mar 2011, 08:45
Quote: vid: POSIX does. libc does not. Right, thanks. But then I am wondering, in what library is code of these wrappers physically present? |
|||
![]() |
|
JohnFound 26 Mar 2011, 13:10
You guys, misguided me! I discovered, that the kernel actually supports multiple timers. The functions are:
Code: sys_timer_create = $103 sys_timer_settime = $104 sys_timer_gettime = $105 sys_timer_getoverrun = $106 sys_timer_delete = $107 Too bad - I just finished library, using setitimer functions. Now I have to rewrite it from scratch. Regards. |
|||
![]() |
|
Tyler 27 Mar 2011, 17:10
vid wrote:
![]() John: It was a conspiracy all along. We were just out to waste your time. ![]() |
|||
![]() |
|
JohnFound 28 Mar 2011, 06:53
Later news from the big timer battle.
![]() POSIX timers appears to support only signal events in the kernel (and callback call events in the glibc wrapper - I really hate how libc and C are enforced in Linux programming) Anyway - signal handlers in Linux are very, very restrictive - they can only change memory and call limited number of functions. Because this, I tried to make the timers to use threads - when the timer expires - the user callback function is started in new thread and after processing ends. This approach appears to work - you can see the sources in the file linux/timer.asm The good thing of the whole story is that now we have almost working Linux threads in FreshLib. |
|||
![]() |
|
revolution 28 Mar 2011, 07:11
Ouch. Using threads for timer expiry sounds very expensive in both memory usage and OS overhead. Isn't there another way?
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.