projects
/
cascardo
/
kernel
/
samples
/
char2
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Use spinlock to freeze system for 5 seconds.
[cascardo/kernel/samples/char2/.git]
/
hellochar.c
diff --git
a/hellochar.c
b/hellochar.c
index
a197a1d
..
180b90c
100644
(file)
--- a/
hellochar.c
+++ b/
hellochar.c
@@
-40,8
+40,10
@@
static ssize_t hello_read(struct file *fp, char __user *buf, size_t sz,
loff_t *pos)
{
unsigned long expire = jiffies + 5 * HZ;
+ spin_lock(&hello_lock);
while (time_after(expire, jiffies))
cpu_relax();
+ spin_unlock(&hello_lock);
return 0;
}