[haiku-commits] r41441 - in haiku/branches/developer/bonefish/signals/src/system/kernel: . arch/m68k arch/ppc arch/x86

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 11 May 2011 16:49:32 +0200 (CEST)

Author: bonefish
Date: 2011-05-11 16:49:31 +0200 (Wed, 11 May 2011)
New Revision: 41441
Changeset: https://dev.haiku-os.org/changeset/41441

Modified:
   
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/m68k/arch_int.cpp
   
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/ppc/arch_int.cpp
   
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/x86/arch_int.cpp
   haiku/branches/developer/bonefish/signals/src/system/kernel/cpu.cpp
   haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp
   haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp
Log:
Replaced more occurrences of gThreadSpinlock by gSchedulerLock where used as
scheduler lock.


Modified: 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/m68k/arch_int.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/m68k/arch_int.cpp
  2011-05-11 13:41:37 UTC (rev 41440)
+++ 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/m68k/arch_int.cpp
  2011-05-11 14:49:31 UTC (rev 41441)
@@ -23,6 +23,7 @@
 #include <smp.h>
 #include <thread.h>
 #include <timer.h>
+#include <util/AutoLock.h>
 #include <util/DoublyLinkedList.h>
 #include <util/kernel_cpp.h>
 #include <vm/vm.h>
@@ -296,9 +297,9 @@
 
        int state = disable_interrupts();
        if (thread->cpu->invoke_scheduler) {
-               GRAB_THREAD_LOCK();
+               SpinLocker schedulerLocker(gSchedulerLock);
                scheduler_reschedule();
-               RELEASE_THREAD_LOCK();
+               schedulerLocker.Unlock();
                restore_interrupts(state);
        } else if (hardwareInterrupt && thread->post_interrupt_callback != 
NULL) {
                restore_interrupts(state);

Modified: 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/ppc/arch_int.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/ppc/arch_int.cpp
   2011-05-11 13:41:37 UTC (rev 41440)
+++ 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/ppc/arch_int.cpp
   2011-05-11 14:49:31 UTC (rev 41441)
@@ -21,6 +21,7 @@
 #include <smp.h>
 #include <thread.h>
 #include <timer.h>
+#include <util/AutoLock.h>
 #include <util/DoublyLinkedList.h>
 #include <util/kernel_cpp.h>
 #include <vm/vm.h>
@@ -243,9 +244,9 @@
 
        cpu_status state = disable_interrupts();
        if (thread->cpu->invoke_scheduler) {
-               GRAB_THREAD_LOCK();
+               SpinLocker schedulerLocker(gSchedulerLock);
                scheduler_reschedule();
-               RELEASE_THREAD_LOCK();
+               schedulerLocker.Unlock();
                restore_interrupts(state);
        } else if (thread->post_interrupt_callback != NULL) {
                restore_interrupts(state);

Modified: 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/x86/arch_int.cpp
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/x86/arch_int.cpp
   2011-05-11 13:41:37 UTC (rev 41440)
+++ 
haiku/branches/developer/bonefish/signals/src/system/kernel/arch/x86/arch_int.cpp
   2011-05-11 14:49:31 UTC (rev 41441)
@@ -16,6 +16,7 @@
 #include <smp.h>
 #include <team.h>
 #include <thread.h>
+#include <util/AutoLock.h>
 #include <vm/vm.h>
 #include <vm/vm_priv.h>
 
@@ -1037,9 +1038,9 @@
 
        cpu_status state = disable_interrupts();
        if (thread->cpu->invoke_scheduler) {
-               GRAB_THREAD_LOCK();
+               SpinLocker schedulerLocker(gSchedulerLock);
                scheduler_reschedule();
-               RELEASE_THREAD_LOCK();
+               schedulerLocker.Unlock();
                restore_interrupts(state);
        } else if (thread->post_interrupt_callback != NULL) {
                restore_interrupts(state);

Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/cpu.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/cpu.cpp 
2011-05-11 13:41:37 UTC (rev 41440)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/cpu.cpp 
2011-05-11 14:49:31 UTC (rev 41441)
@@ -10,13 +10,15 @@
 
 
 #include <cpu.h>
-#include <thread_types.h>
 #include <arch/cpu.h>
-#include <boot/kernel_args.h>
 
 #include <string.h>
 
+#include <boot/kernel_args.h>
+#include <thread_types.h>
+#include <util/AutoLock.h>
 
+
 /* global per-cpu structure */
 cpu_ent gCPU[MAX_BOOT_CPUS];
 
@@ -30,7 +32,7 @@
 }
 
 
-status_t 
+status_t
 cpu_init_percpu(kernel_args *args, int curr_cpu)
 {
        return arch_cpu_init_percpu(args, curr_cpu);
@@ -66,24 +68,15 @@
 bigtime_t
 cpu_get_active_time(int32 cpu)
 {
-       bigtime_t activeTime;
-       cpu_status state;
-
        if (cpu < 0 || cpu > smp_get_num_cpus())
                return 0;
 
-       // We need to grab the thread lock here, because the thread activity
-       // time is not maintained atomically (because there is no need to)
+       // We need to grab the scheduler lock here, because the thread activity
+       // time is not maintained atomically (because there is no need to).
 
-       state = disable_interrupts();
-       GRAB_THREAD_LOCK();
+       InterruptsSpinLocker schedulerLocker(gSchedulerLock);
 
-       activeTime = gCPU[cpu].active_time;
-
-       RELEASE_THREAD_LOCK();
-       restore_interrupts(state);
-
-       return activeTime;
+       return gCPU[cpu].active_time;
 }
 
 

Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp       
2011-05-11 13:41:37 UTC (rev 41440)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/image.cpp       
2011-05-11 14:49:31 UTC (rev 41441)
@@ -364,9 +364,9 @@
                loadingInfo->result = result;
                loadingInfo->done = true;
 
-               // we're done with the team stuff, get the thread lock instead
+               // we're done with the team stuff, get the scheduler lock 
instead
                teamLocker.Unlock();
-               InterruptsSpinLocker threadsLocker(gThreadSpinlock);
+               InterruptsSpinLocker schedulerLocker(gSchedulerLock);
 
                // wake up the waiting thread
                if (loadingInfo->thread->state == B_THREAD_SUSPENDED)

Modified: haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp
===================================================================
--- haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp        
2011-05-11 13:41:37 UTC (rev 41440)
+++ haiku/branches/developer/bonefish/signals/src/system/kernel/team.cpp        
2011-05-11 14:49:31 UTC (rev 41441)
@@ -1661,33 +1661,26 @@
 
        // wait for the loader of the new team to finish its work
        if ((flags & B_WAIT_TILL_LOADED) != 0) {
-               Thread* mainThread;
+               Thread* mainThread = Thread::Get(thread);
+               BReference<Thread> mainThreadReference(mainThread, true);
 
-               cpu_status state = disable_interrupts();
-               GRAB_THREAD_LOCK();
+               InterruptsSpinLocker schedulerLocker(gSchedulerLock);
 
-               mainThread = thread_get_thread_struct_locked(thread);
-               if (mainThread) {
-                       // resume the team's main thread
-                       if (mainThread->state == B_THREAD_SUSPENDED)
-                               scheduler_enqueue_in_run_queue(mainThread);
+               // resume the team's main thread
+               if (mainThread != NULL && mainThread->state == 
B_THREAD_SUSPENDED)
+                       scheduler_enqueue_in_run_queue(mainThread);
 
-                       // Now suspend ourselves until loading is finished.
-                       // We will be woken either by the thread, when it 
finished or
-                       // aborted loading, or when the team is going to die 
(e.g. is
-                       // killed). In either case the one setting 
`loadingInfo.done' is
-                       // responsible for removing the info from the team 
structure.
-                       while (!loadingInfo.done) {
-                               thread_get_current_thread()->next_state = 
B_THREAD_SUSPENDED;
-                               scheduler_reschedule();
-                       }
-               } else {
-                       // Impressive! Someone managed to kill the thread in 
this short
-                       // time.
+               // Now suspend ourselves until loading is finished. We will be 
woken
+               // either by the thread, when it finished or aborted loading, 
or when
+               // the team is going to die (e.g. is killed). In either case 
the one
+               // setting `loadingInfo.done' is responsible for removing the 
info from
+               // the team structure.
+               while (!loadingInfo.done) {
+                       thread_get_current_thread()->next_state = 
B_THREAD_SUSPENDED;
+                       scheduler_reschedule();
                }
 
-               RELEASE_THREAD_LOCK();
-               restore_interrupts(state);
+               schedulerLocker.Unlock();
 
                if (loadingInfo.result < B_OK)
                        return loadingInfo.result;
@@ -2453,9 +2446,9 @@
 static bool
 process_group_has_stopped_processes(ProcessGroup* group)
 {
-       // Grab the global threads spinlock -- it guards the Thread::state 
field,
+       // Grab the scheduler spinlock -- it guards the Thread::state field,
        // which we check in the loop.
-       InterruptsSpinLocker _(gThreadSpinlock);
+       InterruptsSpinLocker schedulerLocker(gSchedulerLock);
 
        Team* team = group->teams;
        while (team != NULL) {
@@ -2988,7 +2981,7 @@
                loadingInfo->result = B_ERROR;
                loadingInfo->done = true;
 
-               InterruptsSpinLocker threadsLocker(gThreadSpinlock);
+               InterruptsSpinLocker schedulerLocker(gSchedulerLock);
 
                // wake up the waiting thread
                if (loadingInfo->thread->state == B_THREAD_SUSPENDED)


Other related posts:

  • » [haiku-commits] r41441 - in haiku/branches/developer/bonefish/signals/src/system/kernel: . arch/m68k arch/ppc arch/x86 - ingo_weinhold