From: premdas.prajosh@gmail.com (Prajosh Premdas)
To: kernelnewbies@lists.kernelnewbies.org
Subject: spin_lock behavior
Date: Wed, 2 Nov 2011 19:23:25 +0530 [thread overview]
Message-ID: <CAAFf3B9v-XSySh5nB6XLN1c_AWdeHhDfaybz_hDopasmfy6TgA@mail.gmail.com> (raw)
Hi
I wrote a sample module which looked like this and i expected the module to
hang as i have used 2 spin_lock simultaneously. But i find the print after
the second spin_lock being printed and the module works perfectly fine. Can
any body please help me in understanding this? I got this problem from a
driver i wrote and had a typo "spin_lock" instead of "spin_unlock" the
driver worked fine and i caught the mistake only during a review
*#include <linux/module.h>*
*#include <linux/spinlock.h>*
*
*
*struct sp_q {*
*spinlock_t spinlock;*
*uint8_t data;*
*};*
*
*
*static int __init sp_lck_init(void)*
*{*
*
*
* struct sp_q test;*
* *
* /* Spin lock Init */*
*
*
* spin_lock_init(&test.spinlock);*
* *
* printk("<1>Test start\n");*
* *
* spin_lock(&test.spinlock);*
* test.data = 0; *
* spin_lock(&test.spinlock); *
* *
* printk("<1>How come???\n");*
* return 0;*
*
*
*}*
*
*
*static void __exit sp_lck_exit(void)*
*{*
*
*
*}*
*
*
*module_init(sp_lck_init);*
*module_exit(sp_lck_exit);*
*MODULE_LICENSE("GPL");*
--
Regards,
Prajosh Premdas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111102/60a34bbd/attachment.html
next reply other threads:[~2011-11-02 13:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-02 13:53 Prajosh Premdas [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-11-02 9:01 spin_lock behavior Prajosh Premdas
2011-11-03 22:04 ` Daniel Baluta
2011-11-03 22:11 ` Jeff Haran
2011-11-04 6:33 ` Prajosh Premdas
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=CAAFf3B9v-XSySh5nB6XLN1c_AWdeHhDfaybz_hDopasmfy6TgA@mail.gmail.com \
--to=premdas.prajosh@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).