Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-28 Thread Eli Billauer
Shachar Raindel wrote: Note that if you have already implemented the give away the CPU while no input, until input arrives, adding the delay bit becomes relatively simple (storing the jiffies value when writing the first byte in the buffer, comparing it to now, if smaller than minimum, going

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-26 Thread Nadav Har'El
On Sat, Apr 23, 2011, Eli Billauer wrote about Re: [Haifux] Implementing read() like UNIX guys like it: if the user calls read and there is data - return what you have to the user without blocking. That is one of the options I considered. The drawback of doing this exactly like

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-26 Thread Nadav Har'El
On Tue, Apr 26, 2011, Eli Billauer wrote about Re: [Haifux] Implementing read() like UNIX guys like it: (...) Second, if the CPU *did* have something useful to do (run other processes, or whatever), it would, causing a bit more time to pass between the read() and it might return more than

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-26 Thread Shachar Raindel
On Tue, Apr 26, 2011 at 11:33 PM, Nadav Har'El n...@math.technion.ac.il wrote: On Tue, Apr 26, 2011, Eli Billauer wrote about Re: [Haifux] Implementing read() like UNIX guys like it: (...) Second, if the CPU *did* have something useful to do (run other processes, or whatever), it would

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-23 Thread emild
Hi Eli, Since I don't think that there is a definite answer to your dilemma, I suggest a common solution to it, which you might not like, but here it goes: implement all three behaviors and use module parameters to select and configure each mode. Then you can play and experiment with each of them

[Haifux] Implementing read() like UNIX guys like it

2011-04-22 Thread Eli Billauer
Hello all, I'm implementing a Linux device driver for a piece of hardware I'm working on. It's important for me that it will behave in a classic UNIX way, whatever that means. Now the dilemma: Suppose that the read() method was called with a requested byte count of 512. The driver checks

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-22 Thread Muli Ben-Yehuda
On Fri, Apr 22, 2011 at 01:31:02PM +0300, Eli Billauer wrote: The overall package I'm working on is kind-of general purpose, and it's the package's user who chooses how the hardware input behaves. I can't know anything about the data flow behavior, and still, I want the reads from the

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-22 Thread Eli Billauer
Hi Muli, I'll answer the your last question first: What I'm doing is basically a general-purpose connection between a hardware FIFO within an FPGA and a device file in Linux, with PCI Express as the data transport. That's why I don't know if data will be coming constantly or in small drops

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-22 Thread guy keren
Hi Eli, i'm afraid you're trying to solve the holy grail of non-local files. you can't hold the pole on both sides. first - it does not seem that you have a notion of end of file for your input - is there? the only time when read is allowed to return 0, is when it reached end of file (for a

Re: [Haifux] Implementing read() like UNIX guys like it

2011-04-22 Thread Eli Billauer
Hello Guy, guy keren wrote: first - it does not seem that you have a notion of end of file for your input - is there? As a matter of fact there is: An extra line (in hardware) will say no more data from hardware which will cause an end of file condition on the Linux side. This is not