ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
time(*long) returns the amount of seconds that have passed since some date, its declared in time.h .. why? what are the porpuse of header files? they contain practically no code; never any conditional operations, just alot of definitions, structure declarations and some function prototypes often strangely preceded by a few __s, so wheres the actual library? all i want is a boolean clock function that goes 0 .. 1 .. 0 .. 1 like the actul hardware does
yeah okay this line of inquiry probably doesnt make a whole lot of sense, im just trying to get off the high level programming trip before i forget whats really going on in a computer..
The purpose of the header files is so you can see what functions there are, and what they need as arguments, without having to worry about the implementation getting in the way. I mean, you can assume the glibc functions work, so who cares how the code does it. If you really want to know, download the glibc source.
As far as timers go in hardware... they usually increment a register, and throw an interrupt when it overflows. If all it did was oscillate between 0 and 1 you would have no idea if you missed a cycle or not so it wouldn't be too useful for a timer....
all things of that nature are entirely implementation dependent. if you want to play with low level stuff learn assembly it's awesome. for example, lets say you want to get a `clock' tick in assembly language. if you're on int x86 pentiums, you can use the `rdtsc' instruction. this reads the contents of the timestamp counter register on the processor. this register is incremented once every clock cycle of the processor. the low 32 bits in eax, and the high 32 go in edx. using the low bits a way to measure small time intervals. on a 500mhz comp it overflows once every 8 seconds. if you want, you can also read the whole 64 bits and that doesnt overflow for a loooong time. if you wanted to do it in C, you could do this:
the headers are just definitions so the compiler knows what to do with it, the actual libs are usualy in /lib or other places like /usr/lib, these are alrdy been compiled to from there the loader loads the required imformation into memory when the program runs
ahh beautiful, thank you all. i got a lot of thinking to do
id like to learn assembly, thats what my inquirys all about. i just havent made it to school yet (summer) and am easily confused by some of the terms im finding in the assembly book ive got .. registers for example, now at least i have a better idea about what one is (some piece of hardware that can store a certain amount of electricity, apparantly)
anyway, thanks, now i understand the first few paragraphs of chapter one
-andrew
(software engineering student to become electronics engineering student)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.