All of lore.kernel.org
 help / color / mirror / Atom feed
From: arrao@cdac.in (Raghavendra)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Issue while reading from tty driver
Date: Thu, 18 Sep 2014 15:12:56 +0530	[thread overview]
Message-ID: <541AA920.60705@cdac.in> (raw)

Hello,

I am trying to explore tty drivers. To start with, I am trying to 
implement a simple loop back device(testing with echo and cat).

The code works fine as far as write is concerned. When the user process 
(echo) calls write() on the device, the driver's write_room() is called 
and then write() is being called successfully. After which, the 
flush_chars() function is being called, in which, a work is scheduled to 
resend the data back to the user space. I have used the 
tty_insert_flip_char() and tty_flip_buffer_push() to get the job done. 
But it is so happening that the read process (cat) is blocking. What 
might be the reason for this blocking?

My code could be found here : 
https://github.com/raghav3276/tty_test/blob/master/tty_test.c

The code is written by taking a reference from LDD3, TTY drivers.
I am implementing the driver on Linux-3.12.1 and I have seen that the 
approach has changed slightly!

Also I have a few more questions regarding the flow of data :
1) During write process, I see that the write is being called twice. In 
the first call, the 'actual' data is being transferred until a new line 
is encountered and in the next call, two new lines are being 
transmitted. So is there any specific format for the data that is to be 
passed to the write() function? Is it mandatory to terminate the data 
with new line or NULL or anything else?
2) Is there any criteria that is to be satisfied to support the read 
functionality as the process that is trying to read the data is blocked? 
Any specific flags or minimum buffer count, etc?

Thanks,
Raghavendra

-------------------------------------------------------------------------------------------------------------------------------
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

                 reply	other threads:[~2014-09-18  9:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=541AA920.60705@cdac.in \
    --to=arrao@cdac.in \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.