/[svn]/linuxsampler/trunk/src/common/Thread.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/Thread.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 361 by schoenebeck, Wed Feb 9 01:22:18 2005 UTC revision 392 by schoenebeck, Sat Feb 19 02:40:24 2005 UTC
# Line 22  Line 22 
22    
23  #include "Thread.h"  #include "Thread.h"
24    
25  Thread::Thread(bool RealTime, int PriorityMax, int PriorityDelta) {  Thread::Thread(bool LockMemory, bool RealTime, int PriorityMax, int PriorityDelta) {
26        this->bLockedMemory     = LockMemory;
27      this->isRealTime        = RealTime;      this->isRealTime        = RealTime;
28      this->Running           = false;      this->Running           = false;
29      this->PriorityDelta     = PriorityDelta;      this->PriorityDelta     = PriorityDelta;
# Line 129  int Thread::SetSchedulingPriority() { Line 130  int Thread::SetSchedulingPriority() {
130    
131      if (!isRealTime) return 0;      if (!isRealTime) return 0;
132    
     if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0) {  
         perror("WARNING, can't mlockall() memory!");  
     }  
   
133      /*      /*
134       * set the process to realtime privs       * set the process to realtime privs
135       */       */
# Line 145  int Thread::SetSchedulingPriority() { Line 142  int Thread::SetSchedulingPriority() {
142      }      }
143    
144      if (sched_setscheduler(0, SCHED_FIFO, &schp) != 0) {      if (sched_setscheduler(0, SCHED_FIFO, &schp) != 0) {
145          perror("sched_setscheduler");          perror("Thread: WARNING, can't assign realtime scheduling to thread!");
146          return -1;          return -1;
147      }      }
148  #endif  #endif
# Line 153  int Thread::SetSchedulingPriority() { Line 150  int Thread::SetSchedulingPriority() {
150  }  }
151    
152  /**  /**
153     * Locks the memory so it will not be swapped out by the operating system.
154     */
155    int Thread::LockMemory() {
156        if (!bLockedMemory) return 0;
157        if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0) {
158            perror("Thread: WARNING, can't mlockall() memory!");
159            return -1;
160        }
161        return 0;
162    }
163    
164    /**
165   *  Registers thread destructor callback function which will be executed when   *  Registers thread destructor callback function which will be executed when
166   *  the thread stops it's execution and sets the 'Running' flag to true. This   *  the thread stops it's execution and sets the 'Running' flag to true. This
167   *  method will be called by the __pthread_launcher callback function, DO NOT   *  method will be called by the __pthread_launcher callback function, DO NOT
# Line 184  void* __pthread_launcher(void* thread) { Line 193  void* __pthread_launcher(void* thread) {
193      Thread* t;      Thread* t;
194      t = (Thread*) thread;      t = (Thread*) thread;
195      t->SetSchedulingPriority();      t->SetSchedulingPriority();
196        t->LockMemory();
197      t->EnableDestructor();      t->EnableDestructor();
198      t->Main();      t->Main();
199  }  }

Legend:
Removed from v.361  
changed lines
  Added in v.392

  ViewVC Help
Powered by ViewVC