From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <37396.128.107.253.38.1111796571.squirrel@www.infernopark.com> In-Reply-To: <20050325183606.GA93332@smp500.sitetronics.com> References: <26029ec71211f29300ddd8b5225f1e38@coraid.com> <20050325183606.GA93332@smp500.sitetronics.com> Date: Fri, 25 Mar 2005 18:22:51 -0600 Subject: Re: [9fans] tsleep / timer questions From: vdharani@infernopark.com To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> User-Agent: SquirrelMail/1.4.2 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: 2b97ceb8-ead0-11e9-9d60-3106f5b1d025 > Related to my work writing a driver for the Ziatech ZT5503 SBC > watchdogs, I've come up with a question. > > Obviously the watchdog needs to be `strobed' at some interval to > keep it from resetting the machine (after it has been enabled). > I'm having troubles figuring out how to do this. > > Taking a look at the driver for the Ziatech 5512 watchdog that > Eric Van Hensbergen write for Inferno, I see that he's making > use of addclock0link(), which makes sense. This seems to be > overkill for my needs though. I'm not sure the resolution of the > timer on the ZT5512 blades, but mine have a minimum resolution > of 250ms, which means that they'd be strobed twice in their > timeout period. > > That's not so bad, but some of the other resolutions (the timer > supports 250ms, 500ms, 1s, 8s, 32s, 64s, 128s and 256s > intervals), this can get to be an issue. I personally have no > use for the 256s resolution, and I'm sure I'm the only person on > the planet running Plan 9 on these blades, but I'd really like > to have a driver that's not overkill. > > So, I thought a nifty solution would be to make use of the > rendezvous stuff and call tsleep. But I don't understand how > this should work. When the watchdog is enabled, I need to start > some procedure that never returns. This would be easy in > userland, where I could simply start another thread, but how do > I do this in-kernel. If I've read in /dev/watchdog > > enable resolution 500ms > > and I've parsed that, how do I then call the procedure to do the > timer? > > My procedure looked like (until I realized that it'd > never work if I understand the behavior correctly, which I'm > fairly certain I do): > > void > watchdog_strobe(void) > { > for(;;) { > if (!enabled) > break; > > tsleep(wd_timer, return0, nil, wd_resolution); > inb(IOP_Watchdog); /* Reading the IO port strobes the WD */ > } > } > > So I'm stuck with the problem: how do I enable a separate timer? > > Hope the question is clear. first, i hope i understood your question corectly. second, i use inferno mostly but i guess this will do the trick in plan9 as well. i dont have access to plan9 system next to me to check this. kproc() starts a new kernel process starting from the function you pass. so, you will call kproc with watchdog_strobe as the argument. kproc() starts the process and returns immediately. you need to modify watchdog_strobe function as needed by kproc(). hope this helps. thanks dharani