Use spinlock to freeze system for 5 seconds.
[cascardo/kernel/samples/char2/.git] / hellochar.c
index a197a1d..180b90c 100644 (file)
@@ -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;
 }