aboutsummaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2016-06-29 13:48:39 +0200
committerArne H Juul <arnej@yahoo-inc.com>2016-06-29 13:48:39 +0200
commit5c3e66a9f3b9e402909fe357bad800941080eb7d (patch)
treeac1d78a82d5afb23acaf4d174de48495a75ab48f /fastos
parent66f1ddf77182c3e9bea0cec2ecff9830fe3a015a (diff)
remove SetPriority from fastos
* the FastOS mechanism for setting priority on processes and threads wasn't used anywhere, and it did not work on linux anyway.
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/processtest.cpp28
-rw-r--r--fastos/src/tests/threadtest.cpp139
-rw-r--r--fastos/src/vespa/fastos/process.h21
-rw-r--r--fastos/src/vespa/fastos/thread.h20
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp19
-rw-r--r--fastos/src/vespa/fastos/unix_process.h1
-rw-r--r--fastos/src/vespa/fastos/unix_thread.cpp35
-rw-r--r--fastos/src/vespa/fastos/unix_thread.h11
8 files changed, 2 insertions, 272 deletions
diff --git a/fastos/src/tests/processtest.cpp b/fastos/src/tests/processtest.cpp
index 30b4570a776..bb7377f4d42 100644
--- a/fastos/src/tests/processtest.cpp
+++ b/fastos/src/tests/processtest.cpp
@@ -69,13 +69,10 @@ private:
ThreadRunJob(const ThreadRunJob&);
ThreadRunJob& operator=(const ThreadRunJob&);
- FastOS_Process::Priority _processPriority;
const char *_processCmdLine;
int _timeSpent;
public:
- ThreadRunJob (FastOS_Process::Priority processPriority,
- const char *commandLine) :
- _processPriority(processPriority),
+ ThreadRunJob (const char *commandLine) :
_processCmdLine(commandLine),
_timeSpent(0)
{
@@ -94,7 +91,6 @@ public:
if(xproc.Create())
{
- xproc.SetPriority(_processPriority);
xproc.Wait(&returnCode);
}
@@ -423,27 +419,6 @@ public:
PrintSeparator();
}
- void PriorityTest ()
- {
- TestHeader("Process Priority Test");
-
- ThreadRunJob job1(FastOS_Process::PRIORITY_LOWEST, _argv[2]);
- ThreadRunJob job2(FastOS_Process::PRIORITY_HIGHEST, _argv[2]);
- FastOS_ThreadPool pool(128*1024);
- Progress(true, "Starting usecpu-processes with low and high priority...");
- pool.NewThread(&job1);
- pool.NewThread(&job2);
- Progress(true, "Waiting for proccesses to finish...");
- pool.Close();
- int timeJob1 = job1.GetTimeSpent();
- int timeJob2 = job2.GetTimeSpent();
-
- Progress(timeJob1 > timeJob2, "Job1 (low priority) %d ms", timeJob1);
- Progress(timeJob1 > timeJob2, "Job2 (high priority) %d ms", timeJob2);
-
- PrintSeparator();
- }
-
void NoInheritTest ()
{
TestHeader("No Inherit Test");
@@ -480,7 +455,6 @@ public:
printf("grep for the string '%s' to detect failures.\n\n", failString);
NoInheritTest();
- PriorityTest();
PollWaitTest();
IPCTest();
ProcessTests(false, true, false);
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index 43ef6aef82a..ed39f8df189 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -39,7 +39,6 @@ public:
double *timebuf;
double average;
int result;
- FastOS_Thread::Priority threadPri;
FastOS_ThreadId _threadId;
Job *otherjob;
int bouncewakeupcnt;
@@ -56,7 +55,6 @@ public:
timebuf(NULL),
average(0.0),
result(-1),
- threadPri(FastOS_Thread::PRIORITY_NORMAL),
_threadId(),
otherjob(NULL),
bouncewakeupcnt(0),
@@ -770,120 +768,6 @@ public:
PrintSeparator();
}
- void PriorityTest (int sign)
- {
- if(sign == 1)
- TestHeader("Priority Test (positive)");
- else
- TestHeader("Priority Test (negative)");
-
- const int numThreads = 5;
-
- FastOS_ThreadPool pool(128*1024);
- Job jobs[numThreads];
-
- int i;
- FastOS_BoolCond boolcondition;
- double *timebuf = new double[numThreads * PRI_TIME_COUNT];
-
- boolcondition.SetBusy();
-
- for(i=0; i<numThreads; i++)
- {
- jobs[i].code = PRIORITY_TEST;
- jobs[i].boolcondition = &boolcondition;
- jobs[i].timebuf = &timebuf[i*PRI_TIME_COUNT];
- jobs[i].threadPri = static_cast<FastOS_Thread::Priority>((-2+i)*sign);
- jobs[i].average = 0;
- jobs[i].ownThread = pool.NewThread(this,
- static_cast<void *>(&jobs[i]));
-
- bool rc=(jobs[i].ownThread != NULL);
- Progress(rc, "CreatingThread %d", i+1);
- }
-
- // Start testing
- Progress(true, "Start testing...");
- boolcondition.ClearBusyBroadcast();
-
- Progress(true, "Waiting for threads to finish using pool.Close()...");
- pool.Close();
- Progress(true, "Pool closed.");
-
- double firstTime, lastTime, totalTime;
- firstTime = lastTime = timebuf[0];
-
- for(i=0; i<(numThreads * PRI_TIME_COUNT); i++)
- {
- double timevalue = timebuf[i];
-
- if(timevalue < firstTime)
- firstTime = timevalue;
-
- if(timevalue > lastTime)
- lastTime = timevalue;
-
- int job = (i/PRI_TIME_COUNT);
- jobs[job].average += timevalue;
- }
-
- totalTime = (lastTime - firstTime);
-
- for(i=0; i<numThreads; i++)
- {
- const int slen=45;
-
- char timestr[slen+1];
- memset(timestr, ' ', slen);
- timestr[slen] = '\0';
-
- double *p = &timebuf[i*PRI_TIME_COUNT];
-
- for(int j=0; j<PRI_TIME_COUNT; j++)
- {
- int pos = static_cast<int>
- (((*p++) - firstTime) * (slen-1) / totalTime);
- timestr[pos] = '*';
- }
-
- Progress(true, "Pri %2d: %s", jobs[i].threadPri, timestr);
- }
-
- char averagestr[80];
-
- averagestr[0] = '\0';
-
- for(i=0; i<numThreads; i++)
- {
- jobs[i].average /= PRI_TIME_COUNT;
-
- // convert average to percent
- jobs[i].average = (jobs[i].average - firstTime) / totalTime;
-
- sprintf(&averagestr[strlen(averagestr)], "%.3f ", jobs[i].average);
- }
- Progress(true, "Percentages: %s", averagestr);
-
- bool okExecution=true;
-
- for(i=0; i<(numThreads-1); i++)
- {
- double val1 = jobs[i].average * sign;
- double val2 = jobs[i+1].average * sign;
-
- if(val1 < val2)
- {
- okExecution = false;
- break;
- }
- }
-
- Progress(okExecution, "Checking order of execution");
- delete [] timebuf;
-
- PrintSeparator();
- }
-
void ThreadIdTest ()
{
const int numThreads = 5;
@@ -1235,8 +1119,6 @@ int ThreadTest::Main ()
TryLockTest();
TimedWaitTest();
ThreadIdTest();
- PriorityTest(1);
- PriorityTest(-1);
SignalTest();
BroadcastTest();
CreateSingleThread();
@@ -1285,27 +1167,6 @@ void ThreadTest::Run (FastOS_ThreadInterface *thread, void *arg)
switch(job->code)
{
- case PRIORITY_TEST:
- {
- thread->SetPriority(job->threadPri);
-
- job->boolcondition->WaitBusy();
- double *p = job->timebuf;
- for(int i=0; i<PRI_TIME_COUNT; i++)
- {
- for(int j=0; j<8192; j++)
- {
- busyCnt = busyCnt*10;
- }
-
- FastOS_Time now;
- now.SetNow();
-
- *p++ = now.MilliSecs();
- }
- break;
- }
-
case SILENTNOP:
{
job->result = 1;
diff --git a/fastos/src/vespa/fastos/process.h b/fastos/src/vespa/fastos/process.h
index 01e88761704..e407d45d079 100644
--- a/fastos/src/vespa/fastos/process.h
+++ b/fastos/src/vespa/fastos/process.h
@@ -100,18 +100,6 @@ public:
};
/**
- * Process priorities.
- */
- enum Priority
- {
- PRIORITY_LOWEST = -2,
- PRIORITY_BELOW_NORMAL = -1,
- PRIORITY_NORMAL = 0,
- PRIORITY_ABOVE_NORMAL = 1,
- PRIORITY_HIGHEST = 2
- };
-
- /**
* Constructor. Does not start the process, use @ref Create or
* @ref CreateWithShell to actually start the process.
* @param cmdLine Command line
@@ -294,15 +282,6 @@ public:
{
return _cmdLine;
}
-
- /**
- * Set process priority. Higher priorities than normal might
- * require adminstrator privileges. PRIORITY_BELOW_NORMAL and
- * PRIORITY_ABOVE_NORMAL are on some OSes mapped to
- * PRIORITY_LOWEST and PRIORITY_HIGHEST, respectively.
- * @return Boolean success / failure
- */
- virtual bool SetPriority (Priority priority) = 0;
};
#include <vespa/fastos/unix_process.h>
diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h
index a6ef359342a..6eba3470176 100644
--- a/fastos/src/vespa/fastos/thread.h
+++ b/fastos/src/vespa/fastos/thread.h
@@ -350,26 +350,6 @@ public:
static bool Sleep(int ms);
/**
- * Thread priorities. The range is -2..2. A higher number
- * indicates higher priority.
- */
- enum Priority
- {
- PRIORITY_LOWEST = -2,
- PRIORITY_BELOW_NORMAL = -1,
- PRIORITY_NORMAL = 0,
- PRIORITY_ABOVE_NORMAL = 1,
- PRIORITY_HIGHEST = 2
- };
-
- /**
- * Set thread priority.
- * @param priority New thread priority.
- * @return Boolean success / failure
- */
- virtual bool SetPriority (const Priority priority) = 0;
-
- /**
* Instruct a thread to exit. This could be used in conjunction with
* @ref GetBreakFlag() in a worker thread, to have cooperative thread
* termination. When a threadpool closes, all threads in the pool will
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index 394b41eb986..6dfeea7376f 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -1979,22 +1979,3 @@ bool FastOS_UNIX_ProcessStarter::Detach(FastOS_UNIX_Process *process)
process->_app->ProcessUnlock();
return rc;
}
-
-bool FastOS_UNIX_Process::SetPriority (Priority priority)
-{
- int newPriority;
-
- switch (priority)
- {
- case PRIORITY_LOWEST: newPriority = 20; break;
- case PRIORITY_BELOW_NORMAL: newPriority = 10; break;
- case PRIORITY_NORMAL: newPriority = 0; break;
- case PRIORITY_ABOVE_NORMAL: newPriority = -10; break;
- case PRIORITY_HIGHEST: newPriority = -20; break;
- default:
- newPriority = 0;
- }
-
- return (setpriority(PRIO_PROCESS, _pid, newPriority) == 0);
-
-}
diff --git a/fastos/src/vespa/fastos/unix_process.h b/fastos/src/vespa/fastos/unix_process.h
index 269920b5a2a..0629ff60af3 100644
--- a/fastos/src/vespa/fastos/unix_process.h
+++ b/fastos/src/vespa/fastos/unix_process.h
@@ -227,7 +227,6 @@ public:
return true;
}
- bool SetPriority (Priority pri);
void SetRunDir(const char *runDir);
void SetStdoutRedirName(const char *stdoutRedirName);
void SetStderrRedirName(const char *stderrRedirName);
diff --git a/fastos/src/vespa/fastos/unix_thread.cpp b/fastos/src/vespa/fastos/unix_thread.cpp
index fe92bafb47b..88d15921af3 100644
--- a/fastos/src/vespa/fastos/unix_thread.cpp
+++ b/fastos/src/vespa/fastos/unix_thread.cpp
@@ -62,48 +62,13 @@ bool FastOS_UNIX_Thread::Initialize (int stackSize, int stackGuardSize)
pthread_attr_destroy(&attr);
- if (rc && pthread_getschedparam(_handle, &_normal_policy,
- &_normal_schedparam) == 0)
- {
- _schedparams_ok = true;
- }
- _schedparams_changed = false;
-
return rc;
}
void FastOS_UNIX_Thread::PreEntry ()
{
- if (_schedparams_changed) {
- _schedparams_changed = false;
- SetPriority(FastOS_Thread::PRIORITY_NORMAL);
- }
}
-bool FastOS_UNIX_Thread::SetPriority (const Priority priority)
-{
- bool rc=false;
-
- if(_schedparams_ok)
- {
- struct sched_param schedparam;
-
- schedparam = _normal_schedparam;
- schedparam.sched_priority = (priority +
- _normal_schedparam.sched_priority);
-
- if (pthread_setschedparam(_handle, _normal_policy,
- &schedparam) == 0)
- {
- rc = true;
- _schedparams_changed = true;
- }
- }
-
- return rc;
-}
-
-
FastOS_UNIX_Thread::~FastOS_UNIX_Thread(void)
{
void *value;
diff --git a/fastos/src/vespa/fastos/unix_thread.h b/fastos/src/vespa/fastos/unix_thread.h
index 6d51d1857b7..594865d4e39 100644
--- a/fastos/src/vespa/fastos/unix_thread.h
+++ b/fastos/src/vespa/fastos/unix_thread.h
@@ -19,11 +19,7 @@ private:
protected:
pthread_t _handle;
- struct sched_param _normal_schedparam;
- int _normal_policy;
bool _handleValid;
- bool _schedparams_ok;
- bool _schedparams_changed;
bool Initialize (int stackSize, int stackGuardSize);
void PreEntry ();
@@ -35,11 +31,7 @@ public:
FastOS_UNIX_Thread(FastOS_ThreadPool *pool)
: FastOS_ThreadInterface(pool),
_handle(),
- _normal_schedparam(),
- _normal_policy(0),
- _handleValid(false),
- _schedparams_ok(false),
- _schedparams_changed(false)
+ _handleValid(false)
{}
virtual ~FastOS_UNIX_Thread(void);
@@ -56,7 +48,6 @@ public:
return rc;
}
- bool SetPriority (const Priority priority);
FastOS_ThreadId GetThreadId ();
static bool CompareThreadIds (FastOS_ThreadId a,
FastOS_ThreadId b);