From: Thadeu Lima de Souza Cascardo Date: Thu, 20 May 2010 20:24:24 +0000 (-0400) Subject: Use spinlock to freeze system for 5 seconds. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fkernel%2Fsamples%2Fchar2%2F.git;a=commitdiff_plain;h=refs%2Fheads%2Fspin Use spinlock to freeze system for 5 seconds. --- diff --git a/hellochar.c b/hellochar.c index a197a1d..180b90c 100644 --- 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; }