Created on Tue Sep 04, 2007 4:49 pm with 7 blog posts
The world as seen by one who is a pilgrim here, whose citizenship is in the Kingdom of God.
This presentation points out that the Earth is a pretty accurate clock (on the order of 1 part in 10^9 error), but has some suggestions.
| http://www.leapsecond.com/ wrote: |
• Earth as a frequency standard
• Suggested improvements:
Thoroughly clean, and dry with cloth
Remove surrounding gas and water vapor
Wait for core to cool before use
Re-align axis of rotation (wobbling)
Keep away from nearby moon (tides)
Keep away from sun (tempco)
Re-adjust rate (avoid leap seconds)
|
Based on a .txt file I want to be understandable to novice programmers. Comments on how to make it more understandable, while being faithful to the original forum thread, are welcome. This could get pretty long if I continue to add annotation for every post in the original thread!
How to loop for each element of an enumerated constant in D
PS. This file contains long lines. Enable word wrap to view it easily.
-- Option "enable text wrapping" or "enable word wrapping".
-- Print preview may work without changing any options.
-- Most word processors wrap by default; most text editors don't.
Original discussion:
http://forum.dlang.org/thread/k080v5$4pv$1@digitalmars.com
I would like to annotate this, suitable to a newcomer to the language, possibly even for a beginning programmer.
Alexandr Druzhinin:
" | Quote: |
Hello all.
I have some enum foo { first=1, second=2, fourth=4, sixth=6} and I'd
like to go through this enumeration like it:
foreach(m; foo.min..foo.max) {
bar(m);
}
But without excluding foo.max and correct handle situation when enum
identifiers aren't consequentive.
Thanks in advance |
"
He wants foo to be a collection of named constants. foo is a type, not a variable. A variable of type foo can be declared as:
foo f; // f will be one of first, second, fourth, or sixth
Constants foo.first, etc. can be used anywhere in the program. These values can be stored into an int variable, but only with a cast:
int i = cast(int)foo.fourth; // i will be set to four
(note: in C, enumerated constants are of type int; in D they are unique)
Variables in D will be automatically typed if the type can be determined from context. It is customary in D to declare variables as "auto" to let the compiler figure out the type. Because of the cast to int, "auto i" would result in i being an int. Remove the cast, and "auto i" would cause i to be type foo.
Adventures in Computer Clock Adjustment
I am running Linux and Openntp to keep my time syncronized. Ideally, I should determine about how fast or slow my computer clock runs, and set the kernel's clock-adjustment parameters to a constant which makes it very close on average.
I discovered that on my machine, every time I reboot the clock frequency jumps by 100 parts per million or more, then remains close to the same as long as it runs. This behavior was so unexpected that I decided to examine it further.
The Linux kernel has two parameters to adjust the clock rate, "tick" and "frequency". Tick is the number of times the clock was originally supposed to cycle before it generated an interrupt and incremented the time by 1/100 of a second; nominally 10000. Frequency is a fine-tuning adjustment, such that adding 65,536 (2^16) to it would slow the clock by one part per million (ppm).
If you study the history of time-keeping in Linux, you will discover that these are left over from historical mechanisms and my explanation is somewhat oversimplified. In today's kernels, increasing tick by one will slow the clock by about 100 ppm and increasing frequency by 6.5 million will have the same effect.
There are at least two clock chips which can be chosen in modern cpu's for timekeeping. I have explored switching the source, and had similar results with either one, though I have forgotten the details.
If anyone else is interested in computer timekeeping and/or use of the ntp protocol, feel free to post to this thread.
Instead of a second Ubuntu installation on my main computer, I am now using Ubuntu 7.10 on am IBM Thinkpad laptop I acquired. So far I installed it and it seems to run fine, but it won't connect to the internet through its wireless interface until I get the right device driver installed for it.
Although I will probably install the wireless feature at some point, I got to thinking that there is a better way. If I install a gateway in my main computer, I can use the laptop via a remote window on the main computer, and still forward the internet to the laptop. That requires some network setup that I will have to learn about, so stay tuned for my experience with it.
In my first post about Ubuntu 7.10 (Gutsy Gibbon), I described my efforts to install a test installation inside VirtualBox, hosted on my old-but-stable Ubuntu 6.06 system. By accident, that was posted under Here and There, instead of Computers ( http://www.frihost.com/users/SonLight/blog/vp-82999.html ) .
Unfortunately, I ran into some snags. I only have 512 MB of ram, which isn't a lot to run virtual machines in. Nevertheless, I expected to be able to install successfully, because I used the alternate install CD -- actually a virtual image, not a real CD -- which claims it only requires 32 MB of memory to do an install. I tried it first giving the VM 192 MB, and it bombed. I increased memory to 320 MB. That seemed like it might work, but it became apparent that memory was overflowing, and data was being swapped back and forth between disk and ram, without any real work being done.
I might try running it again by itself, but the idea that I could do an install while working on the computer was one of the features that encouraged me to try it. More memory would probably do the trick, but how much is needed? Can today's operating systems really handle scheduling programs well when memory is limited? I remember operating systems that would only try to run one program at a time if it decided the program's "working set" was too large to share, and would only "thrash" uselessly if there was no program able to run in available memory. Perhaps the processes in a modern OS are too interconnected to take that approach today.
-->
All blog posts (7)