Commit 45992e45 authored by Claes Sjofors's avatar Claes Sjofors

Backup threads started with realtime priority (refs #187)

parent a6b512c8
...@@ -83,6 +83,8 @@ ...@@ -83,6 +83,8 @@
#include "pwr_baseclasses.h" #include "pwr_baseclasses.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_gdh.h" #include "rt_gdh.h"
#include "rt_thread.h"
#include "rt_proc.h"
#include "rt_gdh_msg.h" #include "rt_gdh_msg.h"
#include "rt_bckdef.h" #include "rt_bckdef.h"
#include "co_cdh.h" #include "co_cdh.h"
...@@ -1389,15 +1391,9 @@ pwr_tUInt32 bck_init () ...@@ -1389,15 +1391,9 @@ pwr_tUInt32 bck_init ()
pwr_tBoolean local; pwr_tBoolean local;
pwr_tOName name; pwr_tOName name;
pwr_tDlid dlid; pwr_tDlid dlid;
pthread_t thr_file; thread_s thr_file;
pthread_t thr_coll [2]; thread_s thr_coll[2];
pwr_sAttrRef attrref; pwr_sAttrRef attrref;
#ifdef OS_VMS
$DESCRIPTOR(efcname, BCK_EFC_NAME);
#endif
#if defined OS_POSIX
pthread_attr_t attr;
#endif
/* Create and initialize all memory structures */ /* Create and initialize all memory structures */
...@@ -1432,6 +1428,7 @@ pwr_tUInt32 bck_init () ...@@ -1432,6 +1428,7 @@ pwr_tUInt32 bck_init ()
/* This should eventually use Posix 1003.4 signals */ /* This should eventually use Posix 1003.4 signals */
#ifdef OS_ELN #ifdef OS_ELN
BCK_MAP_AREAS; BCK_MAP_AREAS;
#elif defined OS_VMS #elif defined OS_VMS
sts = sys$ascefc(BCK_EFC, &efcname, 0, 0); sts = sys$ascefc(BCK_EFC, &efcname, 0, 0);
if (EVEN(sts)) lib$signal(sts); /* BUG */ if (EVEN(sts)) lib$signal(sts); /* BUG */
...@@ -1480,51 +1477,16 @@ pwr_tUInt32 bck_init () ...@@ -1480,51 +1477,16 @@ pwr_tUInt32 bck_init ()
/* Activate the disk process /* Activate the disk process
Activate the fast and slow cycle processes */ Activate the fast and slow cycle processes */
#if defined OS_ELN || (defined OS_VMS && !defined(PTHREAD_1003_1C)) sts4a = thread_Create(&thr_file, "bck_file", bck_file_process, NULL);
sts4a = pthread_create(&thr_file, pthread_attr_default, bck_file_process, NULL);
check4a(sts4a, "pthread_create thr_file");
for (c=0; c<2; c++) {
sts4a = pthread_create(&thr_coll[c], pthread_attr_default, bck_coll_process, (void *)c);
check4a(sts4a, "pthread_create thr_coll");
}
#elif defined(OS_VMS) && defined(PTHREAD_1003_1C)
sts4a = pthread_create(&thr_file, NULL, bck_file_process, NULL);
check4a(sts4a, "pthread_create thr_file"); check4a(sts4a, "pthread_create thr_file");
for (c=0; c<2; c++) {
sts4a = pthread_create(&thr_coll[c], NULL, bck_coll_process, (void *)c);
check4a(sts4a, "pthread_create thr_coll");
}
#elif defined OS_LYNX && defined(PWR_LYNX_30)
pthread_attr_create(&attr);
sts4a = pthread_create(&thr_file, attr, bck_file_process, NULL);
check4a(sts4a, "pthread_create thr_file");
for (c=0; c<2; c++) {
sts4a = pthread_create(&thr_coll[c], attr, bck_coll_process, (void *)c);
check4a(sts4a, "pthread_create thr_coll");
}
#elif defined OS_POSIX
pthread_attr_init(&attr);
sts4a = pthread_create(&thr_file, &attr, bck_file_process, NULL);
check4a(sts4a, "pthread_create thr_file");
for (c=0; c<2; c++) { for (c=0; c<2; c++) {
sts4a = pthread_create(&thr_coll[c], &attr, bck_coll_process, (void *)(long)c); char name[20];
sprintf( name, "bck_coll%d", c);
sts4a = thread_Create( &thr_coll[c], name, bck_coll_process, (void *)(long)c);
check4a(sts4a, "pthread_create thr_coll"); check4a(sts4a, "pthread_create thr_coll");
} }
#endif
return sts; return sts;
} /* bck_init */ } /* bck_init */
...@@ -1550,6 +1512,9 @@ int main( int argc, char *argv[]) ...@@ -1550,6 +1512,9 @@ int main( int argc, char *argv[])
} }
} }
/* Wait for scheduler to be set */
proc_SchedWait();
errh_Init("pwr_bck", errh_eAnix_bck); errh_Init("pwr_bck", errh_eAnix_bck);
errh_SetStatus( PWR__SRVSTARTUP); errh_SetStatus( PWR__SRVSTARTUP);
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
#include "rt_lst.h" #include "rt_lst.h"
#include "rt_que.h" #include "rt_que.h"
#include "rt_thread.h" #include "rt_thread.h"
#include "rt_proc.h"
#include "rt_thread_msg.h" #include "rt_thread_msg.h"
#include "rt_pwr_msg.h" #include "rt_pwr_msg.h"
#include "rt_ini_event.h" #include "rt_ini_event.h"
...@@ -357,8 +358,6 @@ main (int argc, char *argv[]) ...@@ -357,8 +358,6 @@ main (int argc, char *argv[])
qcom_sQid qid = qdb_cQexport; qcom_sQid qid = qdb_cQexport;
qcom_sQid neth_qid; qcom_sQid neth_qid;
qcom_sQid my_q = qcom_cNQid; qcom_sQid my_q = qcom_cNQid;
pid_t pid;
int count = 0;
int noneth = 0; int noneth = 0;
/* Vnta en stund ... */ /* Vnta en stund ... */
...@@ -368,16 +367,7 @@ main (int argc, char *argv[]) ...@@ -368,16 +367,7 @@ main (int argc, char *argv[])
noneth = 1; noneth = 1;
/* Wait for scheduler to be set */ /* Wait for scheduler to be set */
#if defined OS_LINUX proc_SchedWait();
pid = getpid();
while ((sched_getscheduler(pid) == SCHED_OTHER) &&
(count < 5)) {
sleep(1);
count++;
}
#endif
errh_Init("pwr_qmon", errh_eAnix_qmon); errh_Init("pwr_qmon", errh_eAnix_qmon);
errh_SetStatus( PWR__SRVSTARTUP); errh_SetStatus( PWR__SRVSTARTUP);
......
...@@ -124,3 +124,8 @@ proc_UnloadProgram ( ...@@ -124,3 +124,8 @@ proc_UnloadProgram (
return sts; return sts;
} }
pwr_tStatus proc_SchedWait()
{
return PROC__SUCCESS;
}
...@@ -124,3 +124,8 @@ proc_UnloadProgram ( ...@@ -124,3 +124,8 @@ proc_UnloadProgram (
return sts; return sts;
} }
pwr_tStatus proc_SchedWait()
{
return PROC__SUCCESS;
}
...@@ -124,3 +124,21 @@ proc_UnloadProgram ( ...@@ -124,3 +124,21 @@ proc_UnloadProgram (
return sts; return sts;
} }
pwr_tStatus proc_SchedWait()
{
pid_t pid;
int count = 0;
int sched;
pid = getpid();
while (((sched = sched_getscheduler(pid)) == SCHED_OTHER) &&
(count < 5)) {
sleep(1);
count++;
}
if ( sched == SCHED_OTHER)
return PROC__NOSCHED;
return PROC__SUCCESS;
}
...@@ -124,3 +124,8 @@ proc_UnloadProgram ( ...@@ -124,3 +124,8 @@ proc_UnloadProgram (
return sts; return sts;
} }
pwr_tStatus proc_SchedWait()
{
return PROC__SUCCESS;
}
...@@ -124,3 +124,8 @@ proc_UnloadProgram ( ...@@ -124,3 +124,8 @@ proc_UnloadProgram (
return sts; return sts;
} }
pwr_tStatus proc_SchedWait()
{
return PROC__SUCCESS;
}
...@@ -124,3 +124,21 @@ proc_UnloadProgram ( ...@@ -124,3 +124,21 @@ proc_UnloadProgram (
return sts; return sts;
} }
pwr_tStatus proc_SchedWait()
{
pid_t pid;
int count = 0;
int sched;
pid = getpid();
while (((sched = sched_getscheduler(pid)) == SCHED_OTHER) &&
(count < 5)) {
sleep(1);
count++;
}
if ( sched == SCHED_OTHER)
return PROC__NOSCHED;
return PROC__SUCCESS;
}
...@@ -94,6 +94,7 @@ pwr_tStatus proc_UnloadProgram (proc_sProcess*); ...@@ -94,6 +94,7 @@ pwr_tStatus proc_UnloadProgram (proc_sProcess*);
pwr_tStatus proc_RegisterObject(pwr_tOid); pwr_tStatus proc_RegisterObject(pwr_tOid);
pwr_tStatus proc_TimeStamp(); pwr_tStatus proc_TimeStamp();
pwr_tStatus proc_SchedWait();
#endif #endif
......
...@@ -42,4 +42,5 @@ timedout <call has timed out> /info ...@@ -42,4 +42,5 @@ timedout <call has timed out> /info
insvirmem <insufficient virtual memory> /error insvirmem <insufficient virtual memory> /error
nyi <not yet implemented> /error nyi <not yet implemented> /error
anix <zero errh_eAnix> /error anix <zero errh_eAnix> /error
nosched <scheduler not set> /error
.end .end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment