电子产品世界 » 论坛首页 » 综合技术 » 通讯及无线技术 » about the PIP Module

共3条 1/1 1 跳转至

about the PIP Module

2002-12-12 20:24:00    评分
实在想不明白DSP/BIOS中的PIP模块中的函数PIP_get为什么要调用notifyReader函数,还有就是PIP_alloc为什么要调用notifyWriter函数?你想啊,PIP_put函数执行后,read end肯定有一帧数据可读,同时这个函数也调用了notifyReader函数,如果我让这个函数产生一个软中断,这个软中断的任务就是把这个可读帧中的数据给读出去,里面必然要用到PIP_get函数来确定帧的起始地址和帧的长度,那么这样的话岂不是还要调用一次notifyReader函数,这不是重复了吗,都已经在读了,还通知谁去读呀,又没新的可读帧到来?我们有办法来避免这次重复,但是觉得PIP_get中调用notifyReader函数实在没有必要,其目的是什么呢?faint,实在想不明白!!!!

关键词: about     Module     函数    

2002-12-13 20:10:00    评分
来自TI官方网站discussion group的回答 Hi, I see your concern but it does make sense. Generally, PIP notification is only done in one direction. For example, if a PIP is used for input, then the notifyReader function is used and the notifyWriter function is set to nothing. For an output pip, notifyWriter is usually specified and notifyReader is left to nothing. For example, many input data streams are interrupt driven meaning the CPU gets an interrupt when the data is ready. The interrupt service routine (ISR) will then put the data frame into the PIP via PIP_put(). PIP_put() will in turn call notifyReader to let the other end of the PIP know there is new data available. There is no need for notifyWrite because it's interrupt driven. You can apply the same logic for an output stream. The point is, you usually only use one of the notification routines. The other one is left to unused in the config tool. So, let's consider the case of an input PIP. You assign the notifyreader function but leave the nnotifyWriter function to nothing. Input data comes in and the CPU get's an interrupt. The input ISR calls PIP_alloc() then PIP_put(). There's no notifyWriter function specified so PIP_alloc() doesn't call it. PIP_put() does call notifyReader. Since you don't want the the reader function to execute from the context of the ISR, you generally set the notifyReader function to SWI_post(). This means an SWI is posted everytime you do a PIP_put() from your ISR. Eventually the ISR exits and the SWI executes. It's in the SWI function where you call PIP_get() to get the frame. PIP_get() will check the PIP and if more frames are still present in the PIP, it will again call notifyReader and hence call SWI_post() again. This is done to keep the pipe flowing. Consider this, the interrupt service routine put two frames into the PIP back to back before exiting. this means notifyReader was called twice and hence, SWI_post() was called twice. There is no count on SWI posts so it can only be pending once at any given time. However, the ISR posted it twice. What happens is, when the SWI finally executes and does a PIP_get(), it gets one frame. However, PIP_get() will detect that there is still another frame in the PIP and will post the SWI again. Hence, while your SWI is executing, it was posted to run again. As soon as the SWI exits and depending on other threads, it will run again because it was posted. When it runs again it again does a PIP_get() and gets that last frame from the PIP. Now the PIP is empty and PIP_get() will not post the SWI again. If this wasn't this way, you would have to check the PIP at the end of your SWI function and repost the SWI if the PIP wasn't empty. BIOS does this for you. This is a long reply but hope it helps. Regards, -DspGuru

2002-12-13 20:23:00    评分
Hi,DspGuru. Thank you for your wonderful explanation very much.Now I have understood that why notifyReader was called in PIP_get().Let me tell you what I think.It is that the interrupt service routine(ISR) is trigerd twice or more times continuously but the software interrupt(SWI) has not enough time and priority to run.The SWI will run until the ISR finished and is not continous no longer.At this time,several frames are put at the read-end,but only one SWI is pending and the ohers are covered if notifyReader is not called in the PIP_get().So the SWI excutes only once and the several frames can not be readed in time.So notifyReader called in PIP_get() is necessary.right?:)Thank you again from my heart.

共3条 1/1 1 跳转至


匿名不能发帖!请先 [ 登陆 注册 ]