[SCore-users] Developing with PM

Masao Uebayashi uebayasi at pultek.co.jp
Wed Oct 23 17:20:26 JST 2002


Hello,

I'm another one who's trying to port PM2.

> > Call pmGetFd() function to obtain file descriptors to select.
> 
> The question was more like how to attach an fd to a context, but I see 
> that pmCreateAttachFd is the only one which can output a fd...

As far as I read the code, an fd is accosiated with a context by the
device number of the device file opened by a process.  System calls
like poll() can identify which context the fd (or `struct file' in the
kernel) directs to only by knowing the fd's device number.

For example,
myri_pm_poll at SCore/pm2/arch/myrinet/driver/linux/pm_myrinet.c looks
like

static unsigned int
myri_pm_poll(struct file *file, poll_table * wait)
{
	kdev_t dev = file->f_dentry->d_inode->i_rdev;	 /* Device number */
	struct myri_softc *sc = &myri_sc[PM_UNIT(dev)];	 /* Which softc? */
	struct myri_ctx *cp = &sc->context[PM_CTX(dev)]; /* Which context? */

	poll_wait(file, &cp->selwait, wait);
	if (cp->intr_pend) {
		cp->intr_pend = 0;
		return POLLIN;
	}
	return 0;
}

> > Read the source code :-)

This seems to me not a very good (good for users) reply in terms of
promotion, doesn't it? :-)

Regards,

Masao



More information about the SCore-users mailing list