<br><br><div class="gmail_quote">On Sun, Jul 17, 2011 at 4:52 PM, Bond <span dir="ltr"><<a href="mailto:jamesbond.2k.g@gmail.com">jamesbond.2k.g@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Sun, Jul 17, 2011 at 9:17 PM, Anuz Pratap Singh Tomar<br>
<div><div></div><div class="h5"><<a href="mailto:chambilkethakur@gmail.com">chambilkethakur@gmail.com</a>> wrote:<br>
><br>
><br>
> On Sun, Jul 17, 2011 at 4:40 PM, Bond <<a href="mailto:jamesbond.2k.g@gmail.com">jamesbond.2k.g@gmail.com</a>> wrote:<br>
>><br>
>> On Sun, Jul 17, 2011 at 9:04 PM, Anuz Pratap Singh Tomar<br>
>> <<a href="mailto:chambilkethakur@gmail.com">chambilkethakur@gmail.com</a>> wrote:<br>
>> ><br>
>> ><br>
>> > On Sun, Jul 17, 2011 at 4:10 PM, Bond <<a href="mailto:jamesbond.2k.g@gmail.com">jamesbond.2k.g@gmail.com</a>> wrote:<br>
>> >><br>
>> >> On Tue, Jul 5, 2011 at 11:13 AM, Prashant Shah <<a href="mailto:pshah.mumbai@gmail.com">pshah.mumbai@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > Hi,<br>
>> >> ><br>
>> >> > On Tue, Jul 5, 2011 at 9:45 AM, Bond <<a href="mailto:jamesbond.2k.g@gmail.com">jamesbond.2k.g@gmail.com</a>><br>
>> >> > wrote:<br>
>> >> >> This is an interview question.<br>
>> >> >> My answer was<br>
>> >> >> In unix it simply opens the device node as a file and sends/receives<br>
>> >> >> data and commands from it.<br>
>> >> >><br>
>> >> ><br>
>> >> > A little more detailed method :<br>
>> >> ><br>
>> >> > Userland read/write to the file -> Calls C Library read/write<br>
>> >> > functions -> Makes System Calls for read/write -> (now inside kernel)<br>
>> >> > -> Process the system calls (check parameter, etc) -> Refer the<br>
>> >> > file_operations structure for that file -> Call the corresponding<br>
>> >> > read/write function.<br>
>> >> ><br>
>> >><br>
>> >> This is not correct.If you answer this in interview which I faced as I<br>
>> >> did not get that job even you will not.<br>
>> >> The answers on this mailing list did not helped.If you would have been<br>
>> >> in the interview and given these answers it will not work.<br>
>> >> Initially I posted the question on list I was expecting I missed some<br>
>> >> thing or interviewer was blabbering more.But I gave 2-3 more<br>
>> >> interviews<br>
>> >> and all of them asked me same and I gave the answers which I learned<br>
>> >> in this thread but I was not selected.<br>
>> >><br>
>> >> --<br>
>> ><br>
>> ><br>
>> > This list is not an interview question answering mailing list.<br>
>> > Not getting selected have nothing to do with answers being right or<br>
>> > wrong.<br>
>> > Being selected in an interview has a lot of other factors.<br>
>> ><br>
>> ><br>
>> Why do not you understand that this has nothing to my selection what I<br>
>> wanted to know is how does the app gets connected to device.And your<br>
>> rant does not help to understand.The answers given on this list are of<br>
>> very poor quality as usual.<br>
>> As an example you rather than answering some thing meaningful reproduced<br>
>> rant.<br>
><br>
> Greg Freemyer answered your question with fine details. And the discussion<br>
> that followed elaborated the point.<br>
> But you say all that is NOT correct? on what basis did you say that?<br>
<br>
</div></div>I am reproducing what he answered<br>
<div class="im"><br>
And the interviewer was right! You fell short. And so did everyone<br>
else in this thread. I'm very surprised at the poor answers this<br>
thread generated. Maybe everyone should get a 20+ year old UNIX book<br>
an read it so they know the basic and classic mechanisms.<br>
<br>
My personal favorite old book was<br>
<br>
"The Magic Garden Explained: The Internals of Unix System V Release 4"<br>
<br>
To my surprise Amazon has some copies. New and used. It's 20 years<br>
old, but it will give some historical pre-linux context. Remember<br>
your interviewer is likely to be an old timer, so you need to be<br>
familiar with classical UNIX, not just bleeding edge Linux. (Not<br>
that the answers showed familiarity with either, but the classic stuff<br>
should pop of people's minds without thought.)<br>
<br>
Back to the question<br>
<br>
read / write are "data" paths, not control/status/command paths. Yes,<br>
there are drivers that abuse read/write to handle commands, but they<br>
are the exception, not the rule.<br>
<br>
In general, read/write are termed in-band communications and using<br>
them to communicate with ta driver is discouraged. The Linux kernel<br>
encourages out-of-band communications.<br>
<br>
</div><div class="im">Let me simplify the question.<br>
<br>
</div><div class="im">1) What are the FIVE classic system calls for interfacing with a<br>
character device. (ie. If it did not exist in 1970, don't list it).<br>
<br>
</div><div class="im">2) Which of the 5 is still heavily used in the kernel but is<br>
discouraged for new drivers being accepted into the linux kernel?<br>
<br>
</div><div class="im">3) Name at least 3 alternatives that have been routinely used for<br>
out-of-band communication in the Linux kernel since 2000.<br>
<br>
</div><div class="im">Personally, anyone that can't answer those basic questions has failed<br>
a job interview in my mind.<br>
<br>
<br>
</div>Let me know what do you understand from this.<br>
<font color="#888888"><br>
--<br></font></blockquote><div><div class="gmail_quote"><div> </div><br></div></div></div>For one he is pointing out that there are more mechanism to interact with devices than just read/write.<br>When you open a device node, you do not have to necessarily read or write. In most cases its not ever required<br>
The drivers implement many methods like proc, ioctls, the new sysfs each of which can be directly read from or write to or pass some control/command. For example network drivers don't have device nodes, netlink interface or sockets is used to interact with them. <br>
Secondly he is pointing out the fact that some of the interfaces are being deprecated like sysfs will be used for most purpose as compared to proc. <br>In between this discussion, it was also pointed out that seek() call may not be useful for character drivers and its not one of the most important one. <br>
another way for interacting with kernel could be using mmap(). I do not exactly remember how it works, but it has been explained here on this list many times. <br><br>