mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: corbet@lwn.net (Jonathan Corbet)
To: k8 s <uint32@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Doubt Regarding Multithreading and Device Driver
Date: Wed, 27 Apr 2005 09:34:58 -0600	[thread overview]
Message-ID: <20050427153458.20748.qmail@lwn.net> (raw)
In-Reply-To: Your message of "Wed, 27 Apr 2005 20:35:28 +0530." <699a19ea050427080545fb1676@mail.gmail.com>

> I am storing something into struct file*filp->private_data.
> As this is not shared across processes I am not doing any locking
> stuff while accessing or putting anything into it.
> 
> Will There be a race condition in a multithreaded program in the ioctl
> call on smp kernel accessing filp->private_data.

If you are only accessing ->private_date in an ioctl() method, you have
lucked out: straight ioctl() remains protected by the big kernel lock,
and you will not have concurrent accesses.

That said, it's not that hard for you to add the proper locking yourself
and have code which will be robust in the future.  Why not do it right?
There's lots of information in LDD3 (http://lwn.net/Kernel/LDD3/) and
elsewhere on how to do that.

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net


      parent reply	other threads:[~2005-04-27 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-27 15:05 k8 s
2005-04-27 15:10 ` Max Kellermann
2005-04-27 15:30   ` k8 s
2005-04-27 15:41     ` Paulo Marques
2005-04-27 15:46     ` Al Viro
2005-04-27 15:34 ` Richard B. Johnson
2005-04-27 15:34 ` Jonathan Corbet [this message]

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=20050427153458.20748.qmail@lwn.net \
    --to=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=uint32@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®