patch-2.1.126 linux/include/linux/tqueue.h

Next file: linux/include/linux/ufs_fs.h
Previous file: linux/include/linux/shm.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.125/linux/include/linux/tqueue.h linux/include/linux/tqueue.h
@@ -97,19 +97,27 @@
  */
 extern __inline__ void run_task_queue(task_queue *list)
 {
-	struct tq_struct *p;
+	if (*list) {
+		unsigned long flags;
+		struct tq_struct *p;
 
-	p = xchg(list,NULL);
-	while (p) {
-		void *arg;
-		void (*f) (void *);
-		struct tq_struct *save_p;
-		arg    = p -> data;
-		f      = p -> routine;
-		save_p = p;
-		p      = p -> next;
-		save_p -> sync = 0;
-		(*f)(arg);
+		spin_lock_irqsave(&tqueue_lock, flags);
+		p = *list;
+		*list = NULL;
+		spin_unlock_irqrestore(&tqueue_lock, flags);
+		
+		while (p) {
+			void *arg;
+			void (*f) (void *);
+			struct tq_struct *save_p;
+			arg    = p -> data;
+			f      = p -> routine;
+			save_p = p;
+			p      = p -> next;
+			mb();
+			save_p -> sync = 0;
+			(*f)(arg);
+		}
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov