tag:blogger.com,1999:blog-10463454653235579452024-03-13T20:50:27.793+01:00Cateeecatehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-1046345465323557945.post-43019667749910307122007-11-09T11:28:00.000+01:002007-11-09T12:29:08.144+01:00Re: "C and multithreading"On debian planet. I read the <a href="http://www.miriamruiz.es/weblog/?p=129">C and multithreading</a> post of Miriam Ruiz, but I don't agree with some conclusions:<br /><br />First of all, I don't agree with Linus. C standard doesn't allow such optimizations. One of the driving point of C standard (and thus C) is that compiler should do what a programmer write, without much optimization, i.e. C should remain a low level language. It was iterated also for the principles of new C1X standard.<br /><br />Second point. Volatile is not the right solution. volatile means that a variable should be read every time it is accessed, so the variable should not be but in registers (remember the nearly obsolete register keyword).<br /><br />The problem of multi threading is not only that variables could changes (but this is a fact also of<br />single thread programs, when you write a signal handler [which are specified in C standard and which are handled correctly]), but for semaphores there are "barriers", i.e. you should not move read or write across such barriers.<br /><br />What do volatile have with barriers? Nothing. If you read the standard (you can check also only the one page C appendix), you see that C specify what are the "standard" barrier, and they are nearly in all obvious points (i.e. a ";" is also a barrier), so moving instructions is "illegal" for C.<br />Ok. volatile had few other barriers, but across ";" there is already a barrier, so volatile is not the solution of barrier problem (AB locking).<br /><br />References: see <a href="http://clc-wiki.net/wiki/clc-wiki">C wiki</a> and <a href="http://www.open-std.org/JTC1/SC22/WG14/www/standards">C standard</a>.catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com1tag:blogger.com,1999:blog-1046345465323557945.post-84230828837161183952007-11-01T11:23:00.000+01:002007-11-01T11:43:24.979+01:00Linux Kernel Driver DataBaseThis weekend I finally finished the <a href="http://cateee.net/lkddb/">Linux Kernel Driver DataBase</a> . Really I started this project in 2000, but in 2001 after some flames in the LKML (for CML2, the configuration engine used by my project) I put the project in a long hibernation. Now I had some time to finish it.<br /><br />LKDDb is a database of hardware (and protocols), kernel configuration items and associated kernel driver files. Actually it has nearly 6000 entries (see the <a href="http://cateee.net/lkddb/statistics.html">statistics</a>). The database is generated automagically, quite fast: it take 2 minutes to scan the whole kernel source, and to interpret it. Unfortunately it is not complete and not accurate (I'm not sure if there is some black-list in kernel, but my scanner cannot distinguish the black-list with the supported hardware list).<br /><br />Now I'm looking for some application of the database. In 2001 it seemed that there was some interest, but let see.<br /><br />As a prototype, I dis-hibernate also the <a href="http://cateee.net/autokernconf/index.html">AutoKernConf</a>, an automagical kernel configuration. The old version was a more powerful, so I need to <span style="font-style: italic;">forward-port</span> some old features. BTW I changed an other time the project name: autoconfig was too similar to existing projects, kautoconfig, kernfig, kernautoconf were other names, but I like better the new name, and I can use the <span style="font-style: italic;">automagical </span>word in the description ;-)<br /><br />Do you see other uses of the database?catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com3tag:blogger.com,1999:blog-1046345465323557945.post-29033591432269727912007-03-09T10:50:00.000+01:002007-03-09T11:41:34.834+01:00ICANN Factsheet on last DNS root server attackYesterday <a href="http://www.icann.org">ICANN</a> published an interesting article about last attack of root servers (6 February 2007): see <a href="http://www.icann.org/announcements/announcement-08mar07.htm">http://www.icann.org/announcements/announcement-08mar07.htm</a> . The paper is not so detailed and technical as one should expect, anyway it is worth to read it.<br /><br />It seems that also the remaining <a href="http://en.wikipedia.org/wiki/Root_nameserver">root servers</a> should move to <a href="http://en.wikipedia.org/wiki/Anycast">anycast</a>. I think this is good, but it will works reliable with TCP? Do someone use TCP to query DNS servers? Why is it not disabled? It seems that all root servers accept TCP (<span style="font-family: courier new;"> dig @l.root-servers.net. . NS +tcp).<br /><br /></span>A side note: as you can see, root servers don't give you yet the IPv6 addresses of root servers. Now they do some test, prior to broke the root server 512-bytes packet rule. We are still away to the full IPv4/IPv6 inter-operative nets.<span style="font-family: courier new;"><span style="font-family: webdings;"></span><br /></span><br />The last recommendation is: "<span style="font-style: italic;">ISPs should only accept DNS queries from trusted sources (i.e., their own customers) rather than allow anyone to use their servers." <span style="font-style: italic;">. </span></span>This rule (on recursive queries) is already a well know rule, and I I think it is less problematic of mail-rely (ev. with SPF), but on the other side, we are moving to the point that we should trust our ISP and our ISP will firewall "non-proxied" traffic.<br /><br />As last point, the fact sheet cite two <a href="http://en.wikipedia.org">wikipedia</a> articles. Wikipedia is so good, or there are not better (updated) documentation on the net?catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com1tag:blogger.com,1999:blog-1046345465323557945.post-61318905206519025272006-10-28T11:04:00.000+02:002006-10-29T21:40:40.338+01:00shell: parallel execution with timeoutsFrom time in time I was looking how to run a command with a timeout (in a shell script). I never put big efford to find the solution, because I always found a easyer (and probably better) workaround. But few days ago, in a discussion in the austing group (POSIX standardization), I found the solution, in an elegant manner, and it permit also to run commands in parallel.<br /><br />The solution (it works on bash, dash, and it seems posix compatible, but you should test, because the discussion was about the different behaviours of $! in bash and kornshell):<br /><pre wrap=""> # run command1 in background, and the sleeping killer<br />command1 &<br />pid=$!<br />( sleep 60; kill $pid ) &<br /># other stuffs<br />command2<br /># wait command1<br />wait $pid<br /><br /></pre>Note: kill (the shell buildin) prints some error messages, which you should filter<br />Note: Security: the methods is not very clean and secure. If an user can force system to recycle the PID, the scripts could do unintended things.<br /><br />I this trick can be used to parallel the init script (parallelize within the script, not "run scripts in parallel", as the current trend).<br />So another short tip: Debian sleep support "floating sleep", so use sleep .1 istead of sleep 1, to speed up the init scripts (module loading, waiting for devices, net,...). Unfortunately most of the debian scripts use integer sleeps.catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com8tag:blogger.com,1999:blog-1046345465323557945.post-1361219801575460832006-10-18T09:09:00.000+02:002006-10-18T10:09:52.037+02:00ntp: keeping the right timeThis is an other topic inspired by <span style="font-family:courier new;"><a style="font-family: courier new;" href="http://www.usenix.org/publications/login/"><span style="color: rgb(0, 102, 0);">;login:</span></a> <span style="font-family: georgia;">(</span><a href="http://www.usenix.org">usenix</a><span style="font-family: georgia;"> magazine). I think it is essential for a computer to have the clock showing the right time, and it is not hard!</span></span><span style="font-family: georgia;"> </span>On my servers I use either <span style="color: rgb(0, 102, 0);">ntpd</span> (the daemon), or 4 time per day a <span style="color: rgb(0, 102, 0);">ntpdate</span> to a nearly ntp server. On my home desktop the ntpdate is run at every boot (because it is never on for long time), and on my ibook the same on linux boot and ntpd on MacOS (which is the default).<br />I don't know what is the better method. A drift of one second is mainly acceptable on my machines, so the ntpdate methond should be the better choice (if the hardware clock is not "broken"). [BTW the debian packages are: <a href="http://packages.debian.org/ntp">ntp</a> and <a href="http://packages.debian.org/ntpdate">ntpdate</a>]<br /><br />Today I joined the <a href="http://www.pool.ntp.org/">ntp pool</a> servers: a list of public (and unrestricted) ntp servers. For my configuration I choosed 6 ntp servers (stratum 2) located in Switzerland.<br /><br />If you don't care to high precise timing, you can use <a href="http://www.pool.ntp.org/">ntp pool</a> servers (check the references to choose the right servers). If you have not yet used ntp, it is the better start. For high precise timing, there are also <a href="http://ntp.isc.org/bin/view/Servers/StratumOneTimeServers">Stratum 1</a> (but read the usage rules) and <a href="http://ntp.isc.org/bin/view/Servers/StratumTwoTimeServers">Stratum 2</a>. Optionally you can also use a GPS clock.<br /><br />References: <a href="http://ntp.isc.org/">ntp project home page</a>. I've also heard that there is a project of one of the BSD to make an alternate (and lighter) implementation.catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com0tag:blogger.com,1999:blog-1046345465323557945.post-27550892949389957702006-10-17T15:44:00.000+02:002006-10-18T09:36:20.061+02:00C99Yesterday I was looking for the changes between the ANSI/ISO C (1989) and the new C99 (ISO 1999). The best information are found in: <a href="http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.htm">http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.htm</a><br />Summary of the main changes:<br /><ul><li>external identifier now are case sensitive and up 31 characters (in old standard a portable program should not rely on case sensitiveness nor to more of 6 chars)</li><li>variable argument on macros</li><li>from C++: <span style="color: rgb(0, 102, 0);">//</span> comment, <span style="color: rgb(0, 102, 0);font-family:courier new;" >inline</span>, declaration and statement can mix,<span style="font-family:courier new;"> </span><span style="color: rgb(0, 102, 0);font-family:courier new;" >for</span> allow declaration in first "argument"<br /></li><li> compound literals</li><li>initializers: <span style="color: rgb(0, 102, 0);font-family:courier new;" >int a[10] = { [5] = 3}; struct {int a,b} c = { .b=3};</span></li><li><span style="color: rgb(0, 102, 0);font-family:courier new;" >long long</span> (64-bit or longer) with <span style="color: rgb(0, 102, 0);font-family:courier new;" >LL</span>, <span style="color: rgb(0, 102, 0);font-family:courier new;" >ll</span>, <span style="color: rgb(0, 102, 0);font-family:courier new;" >ULL </span>and <span style="color: rgb(0, 102, 0);font-family:courier new;" >ull </span>suffixes in costants</li><li><span style="color: rgb(0, 102, 0);font-family:courier new;" >__func__</span> "automatic variable" : <span style="color: rgb(0, 102, 0);font-family:courier new;" >void f(int void) { fprint("me is %s\n", __func__); }</span></li><li><span style="color: rgb(0, 102, 0);font-family:courier new;" >_Bool</span> and if you <span style="color: rgb(0, 102, 0);font-family:courier new;" >#include <stdbool.h></stdbool.h></span> you have <span style="color: rgb(0, 102, 0);font-family:courier new;" >bool</span>, <span style="color: rgb(0, 102, 0);font-family:courier new;" >true </span>and <span style="color: rgb(0, 102, 0);font-family:courier new;" >false</span></li><li><code style="font-family: courier new; color: rgb(0, 102, 0);">restrict</code><span style="color: rgb(0, 102, 0);font-family:courier new;" > </span>keyword to optimize function: you tell compiler that pointers don't point overlapping regions.</li><li>variable-length arrays</li></ul>The<span style="font-weight: bold;"> gcc</span> has a <a href="http://gcc.gnu.org/c99status.html">page</a> about what is implemented and what not.<br /><br />In <a href="http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899">http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899</a> you see the complete standard with the two corrigenda, and the rationale about the new standard. It worth to browse it!catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com0tag:blogger.com,1999:blog-1046345465323557945.post-44460618249555484332006-10-17T10:45:00.000+02:002006-10-18T09:36:38.247+02:00About meAs first post, I'll describe briefly me and my interest. I'm Swiss, I spoke Italian (mother tongue), French, German and English. Maybe this blog would improve my English skills.<br /><br />I'm a Debian Developer (but few packages), I started with Debian in 1996 or 1997 (IIRC) with few floppies disks, than Mandrake (easier to handle packages with floppies), then someone burned my a RedHat, unfortunately with a non free X server, and than I compiled and installed a lot of program from sources (kernel, glibc, gcc...). Finally I used Debian for all home activities as only OS.<br />Recently with my new laptop (iBook), I use dual boot: MacOS and Linux/Debian.<br /><br />I install nearly every kernel from "vanilla sources" since 2.0.28/2.1.8x. I read kernel mailing list<br />since 7-8 years, but I've contributed only with few and small patches.<br /><br />I focus on kernel, security and standards, but I'm also interested in networks (IP, and the organizations behind Internet: IC, IAB, IETF, ICANN, IANA, RFC-editor,...), configuration and low level libraries.<br /><br />I'm a wikipedian (now I think I have nearly 1200 edits in the English edition): anti vandalism, clean-up, swiss topics (mainly about Ticino), wine and filmmaking.<br /><br />I own a small vineyard, and I make also some wine.<br /><br />And a lot of other "minor" interests.catehttp://www.blogger.com/profile/15700217782948121553noreply@blogger.com0