On 9/16/05, Timur Tabi <timur.tabi@xxxxxxxxxxx> wrote: > Fawad Lateef wrote: > > > Can you explain what you are doing ??? like how u are sharing buffer > > b/w user/kernel space, > > I allocate the buffer in the driver, and the application calls mmap() to get a pointer to it. > ya, ok .... I was thinking in terms of block device driver ;) > > whats the method of polling b/c you are saying > > completely de-coupling the driver from the simulator ??? > > The simulator has a bunch of threads that just run on their own, constantly polling the > memory buffer looking for when something has changed. It's inefficient, but it more > closely matches how the real hardware works. > its clear to me your way now, as you are using mmap .... > > Whats your driver do ??? > > It's a standard network driver. > > > Is it working constantly means in a loop ?? > > No, I was talking about the simulator. > > The driver writes data to the memory buffer, and it's supposed to wait until the simulator > writes the response back to the same memory buffer. I just want to know if schedule() > will cause the driver to go to sleep, and give CPU to the simulator application. > Yes, schedule() will certainly sends your driver to sleep and will schedule it to run again; thus give certainly time to other applications to work ... > Basically, I want to know if the following code will work: > > *buffer =100; > while (*buffer == 100) { > schedule(); > } > > What I want to know is whether the schedule() call will give CPU time to the simulator, > which is running as a user-space process. When the simulator runs, it sees that the > buffer has the value 100, and then it does some calculations, and writes a different value > back to the buffer. This should cause "*buffer == 100" to become false. > What i saw is calling schedule in a loop of the kernel thread/process makes it to use 99% of the CPU, if CPU is not doing other stuffs (and might slow down the user space too as it has low priority then kernel space) ... So my idea is to better use schedule_timeout with some small value, so that load on the CPU will be less ........ -- Fawad Lateef -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/