patch-2.1.19 linux/include/asm-sparc64/smp_lock.h
Next file: linux/include/asm-sparc64/socket.h
Previous file: linux/include/asm-sparc64/smp.h
Back to the patch index
Back to the overall index
- Lines: 61
- Date:
Mon Dec 30 12:00:03 1996
- Orig file:
v2.1.18/linux/include/asm-sparc64/smp_lock.h
- Orig date:
Thu Jan 1 02:00:00 1970
diff -u --recursive --new-file v2.1.18/linux/include/asm-sparc64/smp_lock.h linux/include/asm-sparc64/smp_lock.h
@@ -0,0 +1,60 @@
+/* smp_lock.h: Locking and unlocking the kernel on the 64-bit Sparc.
+ *
+ * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
+ */
+
+#ifndef __SPARC64_SMPLOCK_H
+#define __SPARC64_SMPLOCK_H
+
+#include <asm/smp.h>
+#include <asm/bitops.h>
+#include <asm/pgtable.h>
+
+#ifdef __SMP__
+
+extern __inline__ __volatile__ unsigned char ldstub(volatile unsigned char *lock)
+{
+ volatile unsigned char retval;
+
+ __asm__ __volatile__("ldstub [%1], %0" : "=&r" (retval) : "r" (lock));
+ return retval;
+}
+
+/*
+ * Locking the kernel
+ */
+
+/* Knock knock... */
+extern __inline__ void lock_kernel(void)
+{
+ int proc = smp_processor_id();
+
+ while(ldstub(&kernel_flag)) {
+ if(proc == active_kernel_processor)
+ break;
+ do {
+#ifdef __SMP_PROF__
+ smp_spins[smp_processor_id()]++;
+#endif
+ barrier();
+ } while(kernel_flag); /* Don't lock the bus more than we have to. */
+ }
+ active_kernel_processor = proc;
+ kernel_counter++;
+}
+
+/* I want out... */
+extern __inline__ void unlock_kernel(void)
+{
+ if(kernel_counter == 0)
+ panic("Bogus kernel counter.\n");
+
+ if(!--kernel_counter) {
+ active_kernel_processor = NO_PROC_ID;
+ kernel_flag = KLOCK_CLEAR;
+ }
+}
+
+#endif /* (__SMP__) */
+
+#endif /* !(__SPARC64_SMPLOCK_H) */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov