Commit d1b69caf authored by Claes Sjofors's avatar Claes Sjofors

Plc, several plc processes with possibility to set affinity, and plc version removed

parent 6951f26f
This diff is collapsed.
......@@ -141,6 +141,7 @@ typedef struct {
char id[40];
ini_mProc flags;
proc_sProcess proc;
void *objectp;
} ini_sProc;
typedef struct {
......@@ -158,7 +159,8 @@ typedef struct {
ini_sFile applfile;
ini_sFile bootfile;
ini_sFile nodefile;
ini_sFile plcfile;
ini_sFile *plcfile;
int plcfile_cnt;
int busid;
char dir[256];
char bdir[256]; /* Base dir (pwr_load) */
......@@ -206,8 +208,8 @@ char * ini_LoadDirectory (pwr_tStatus*, ini_sContext*);
pwr_tBoolean ini_LoadNode (pwr_tStatus*, ini_sContext*);
pwr_tBoolean ini_LoadVolume (pwr_tStatus*, ini_sContext*, ivol_sVolume*);
FILE *ini_OpenFile (pwr_tStatus*, ini_sContext*, ini_sFile*);
ini_sProc *ini_ProcInsert (pwr_tStatus*, ini_sContext*, char*, char*, int, int, char*, int, int, char*);
void ini_ProcIter (pwr_tStatus*, ini_sContext*, int,
ini_sProc *ini_ProcInsert (pwr_tStatus*, ini_sContext*, char*, char*, int, int, char*, int, int, char*, void*);
void ini_ProcIter (pwr_tStatus*, ini_sContext*, int, int,
void (*func) (pwr_tStatus*, ini_sContext*, ini_sProc*));
void ini_ProcLoad (pwr_tStatus*, ini_sContext*, ini_sProc*);
void ini_ProcStart (pwr_tStatus*, ini_sContext*, ini_sProc*);
......
......@@ -227,9 +227,9 @@ start (
#endif
ini_ProcTable(&sts, cp);
ini_ProcIter(&sts, cp, proc_mProcess_system, ini_ProcLoad);
ini_ProcIter(&sts, cp, proc_mProcess_system, ini_ProcStart);
ini_ProcIter(&sts, cp, proc_mProcess_system, ini_ProcPrio);
ini_ProcIter(&sts, cp, proc_mProcess_system, 0, ini_ProcLoad);
ini_ProcIter(&sts, cp, proc_mProcess_system, 0, ini_ProcStart);
ini_ProcIter(&sts, cp, proc_mProcess_system, 0, ini_ProcPrio);
net_Connect(&sts, &gdbroot->my_aid, &gdbroot->my_qid, NULL, "pwr_ini");
/*if (!qcom_Init(&sts, 0)) {*/
......@@ -240,9 +240,9 @@ start (
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcInit | ini_mEvent_newPlcStart);
ini_ProcIter(&sts, cp, proc_mProcess_user, ini_ProcLoad);
ini_ProcIter(&sts, cp, proc_mProcess_user, ini_ProcStart);
ini_ProcIter(&sts, cp, proc_mProcess_user, ini_ProcPrio);
ini_ProcIter(&sts, cp, proc_mProcess_user, 0, ini_ProcLoad);
ini_ProcIter(&sts, cp, proc_mProcess_user, 0, ini_ProcStart);
ini_ProcIter(&sts, cp, proc_mProcess_user, 0, ini_ProcPrio);
qcom_CreateQ(&sts, &cp->eventQ, NULL, "iniEvent");
if (EVEN(sts)) {
......@@ -406,6 +406,9 @@ restart (
)
{
pwr_tStatus sts;
char time[24];
lst_sEntry *pl;
ini_sProc *pp;
ini_CheckContext(&sts, cp);
......@@ -437,8 +440,11 @@ restart (
ini_ProcTable(&sts, cp);
ini_ProcLoad(&sts, cp, cp->plc);
ini_ProcStart(&sts, cp, cp->plc);
// ini_ProcLoad(&sts, cp, cp->plc);
// ini_ProcStart(&sts, cp, cp->plc);
ini_ProcIter(&sts, cp, proc_mProcess_user, ini_mProc_plc, ini_ProcLoad);
ini_ProcIter(&sts, cp, proc_mProcess_user, ini_mProc_plc, ini_ProcStart);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcInit);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcInitDone, qcom_cTmoEternal);
......@@ -454,16 +460,21 @@ restart (
errh_LogInfo(&cp->log, "Time critical period over, new PLC is running");
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_swapDone);
if (cp->PlcProcess != NULL) {
char time[24];
time_GetTime(&cp->PlcProcess->LastChgTime);
time_Dsub(&cp->PlcProcess->StallTime, &cp->PlcProcess->StartTime, &cp->PlcProcess->StopTime);
time_DtoAscii(&cp->PlcProcess->StallTime, 1, time, sizeof(time));
cp->log.put.type.s = 2;
errh_LogInfo(&cp->log, "IO stall time: %s", time);
cp->np->RestartStallTime = cp->PlcProcess->StallTime;
for (pp = lst_Succ(NULL, &cp->proc_lh, &pl); pp != NULL; pp = lst_Succ(NULL, pl, &pl)) {
if ( pp->flags.m & ini_mProc_plc && pp->objectp) {
pwr_sClass_PlcProcess *plc = pp->objectp;
time_GetTime(&plc->LastChgTime);
if ( time_Dcomp(&plc->StartTime, &plc->StopTime) == 1)
time_Dsub(&plc->StallTime, &plc->StartTime, &plc->StopTime);
else
plc->StallTime = pwr_cNDeltaTime;
time_DtoAscii(&plc->StallTime, 1, time, sizeof(time));
cp->np->RestartStallTime = plc->StallTime;
}
}
cp->log.put.type.s = 2;
errh_LogInfo(&cp->log, "IO stall time: %s", time);
ini_FreeBodies(&sts, cp, 0);
ini_FreeBodies(&sts, cp, 1);
......@@ -671,7 +682,10 @@ createContext (int argc, char **argv)
exit(0);
}
cp->flags.b.plcfile = 1;
strcpy(cp->plcfile.name, argv[i+1]);
cp->plcfile = (ini_sFile *) calloc( 1, sizeof(ini_sFile));
cp->plcfile_cnt = 1;
strcpy(cp->plcfile[0].name, argv[i+1]);
cp->plcfile[0].logOpenFail = errh_LogInfo;
i++;
i_incr = 1;
break;
......
......@@ -51,6 +51,9 @@
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#if defined OS_LINUX
#include <sched.h>
#endif
#include <pwd.h>
#include "pwr.h"
......@@ -79,7 +82,7 @@
#include "rt_pwr_msg.h"
static plc_sProcess *init_process ();
static pwr_tStatus init_plc (plc_sProcess*);
static pwr_tStatus init_plc (plc_sProcess*, char *name);
static void init_threads (plc_sProcess*);
static void start_threads (plc_sProcess*);
static void run_threads (plc_sProcess*);
......@@ -179,7 +182,7 @@ int main (
qcom_WaitAnd(&sts, &pp->eventQ, &qcom_cQini, ini_mEvent_newPlcInit, qcom_cTmoEternal);
init_plc(pp);
init_plc(pp, argv[0]);
create_threads(pp);
init_threads(pp);
......@@ -302,7 +305,8 @@ init_process ()
static pwr_tStatus
init_plc (
plc_sProcess *pp
plc_sProcess *pp,
char *name
)
{
pwr_tStatus sts = PLC__SUCCESS;
......@@ -314,6 +318,12 @@ init_plc (
int msec;
int i;
pwr_tCid cid;
int busid;
int found;
char busidstr[10];
char pp_name[80];
pwr_tObjName oname;
char *s;
sts = gdh_GetNodeObject(0, &oid);
if (EVEN(sts)) {
......@@ -324,15 +334,58 @@ init_plc (
sts = gdh_ObjidToPointer(oid, (void *)&pp->Node);
if (EVEN(sts)) return sts;
sts = gdh_GetClassList(pwr_cClass_PlcProcess, &pp_oid);
if (EVEN(sts)) {
errh_Error("Found no PlcProcess-object\n%m", sts);
return sts;
busid = qcom_MyBus( &sts);
if ( EVEN(sts)) return sts;
sprintf( busidstr, "_%04d_", busid);
s = strstr( name, busidstr);
if ( s) {
strncpy( pp_name, s + 6, sizeof(pp_name));
if ( (s = strchr( pp_name, '.')))
*s = 0;
}
else {
strcpy( pp_name, "");
}
for ( sts = gdh_GetClassList(pwr_cClass_PlcProcess, &pp_oid);
ODD(sts);
sts = gdh_GetNextObject(pp_oid, &pp_oid)) {
sts = gdh_ObjidToName(pp_oid, oname, sizeof(oname), cdh_mName_object);
if (EVEN(sts)) return sts;
if ( cdh_NoCaseStrcmp( pp_name, oname) == 0) {
found = 1;
break;
}
}
if (!found) {
errh_Error("Found no PlcProcess-object %s", pp_name);
return 0;
}
sts = gdh_ObjidToPointer(pp_oid, (void *)&pp->PlcProcess);
if (EVEN(sts)) return sts;
#if defined OS_LINUX
if ( pp->PlcProcess->CpuMask != 0) {
cpu_set_t mask;
CPU_ZERO(&mask);
for ( i = 0; i < 32; i++) {
if ( pp->PlcProcess->CpuMask & 1 << i)
CPU_SET( i, &mask);
}
sts = sched_setaffinity( 0, sizeof(mask), &mask);
if ( sts < 0)
errh_Error("Unable to set affinity mask");
else
errh_Info("Affinity mask set to %d", pp->PlcProcess->CpuMask);
}
#endif
i = 0;
sts = gdh_GetChild( pp_oid, &thread_oid);
while ( ODD(sts)) {
......
......@@ -35,11 +35,10 @@
%#if defined OS_VMS || defined OS_ELN
%# define load_cNameDirectory "pwrp_load:"
%# define load_cDirectory "pwrp_load:"
%# define load_cNamePlc "%splc_%s_%04d_%05d.exe"
%# define load_cNamePlc "%splc_%s_%04d_%s.exe"
%
%# define load_cNameBootList "pwrp_root:[src.db]pwrp_cnf_bootlist.dat"
%# define load_cNameVolumeList "pwrp_root:[src.db]pwrp_cnf_volumelist.dat"
%# define load_cNamePlcVersion "pwrp_root:[src.db]pwrp_cnf_plcvers_%s.dat"
%# define load_cNameDistribute "pwrp_root:[src.db]pwrp_cnf_distribute.dat"
%# define load_cNameSysObject "pwrp_root:[src.db]pwrp_cnf_sysobject.dat"
%# define load_cNameGblVolumeList "pwra_db:pwr_volumelist.dat"
......@@ -52,11 +51,10 @@
%#elif defined OS_POSIX
%# define load_cNameDirectory "pwrp_load"
%# define load_cDirectory "$pwrp_load/"
%# define load_cNamePlc "%splc_%s_%04d_%05d"
%# define load_cNamePlc "%splc_%s_%04d_%s"
%
%# define load_cNameBootList "$pwrp_root/src/db/pwrp_cnf_bootlist.dat"
%# define load_cNameVolumeList "$pwrp_root/src/db/pwrp_cnf_volumelist.dat"
%# define load_cNamePlcVersion "$pwrp_root/src/db/pwrp_cnf_plcvers_%s.dat"
%# define load_cNameDistribute "$pwrp_root/src/db/pwrp_cnf_distribute.dat"
%# define load_cNameSysObject "$pwrp_root/src/db/pwrp_cnf_sysobject.dat"
%# define load_cNameFilePath "$pwrp_root/src/db/pwrp_cnf_dirlist.dat"
......@@ -77,7 +75,7 @@
%
%#define load_cNameAlias "%spwrp_alias.dat"
%#define load_cNameAppl "%sld_appl_%s_%d.txt"
%#define load_cNameOpt "%splc_%s_%04d.opt"
%#define load_cNameOpt "%splc_%s_%04d_%s.opt"
%#define load_cNameBoot "%sld_boot_%s_%04d.dat"
%#define load_cNameNode "%sld_node_%s_%04d.dat"
%#define load_cNameRc "%sld_rc_%s_%04d.dat"
......
......@@ -129,6 +129,7 @@ maxsize <MaxSize is larger than cell size> /error
noseqreset <No SequenceReset object found in main object> /error
compmethod <Invalid compile method> /error
libref <Invalid reference to library hierarchy> /error
misplacedthread <Misplaced thread object> /error
.facility FOE,280 /prefix = FOE__ ! Function object editor
......
......@@ -37,7 +37,7 @@
!
SObject pwrb:Class
!/**
! @Version 2.0
! @Version 3.0
! @Group ProjectConfiguration
! @Summary Build options for plc program
! Configures the build options for the plc program.
......@@ -55,7 +55,12 @@ SObject pwrb:Class
! - function objects from the class volumes NMps, Remote, Misc or Ssabox are
! used.
!
! The object creates an option file $pwrp_exe/plc_'nodename'_'busnumber'.opt
! From V4.8.4 serveral PLC processes can be configured in the same node, and also
! several BuildOptions object can be configured. Which process a BuildOptions belongs
! to is specified by inserting the name of the PlcProcess object into the PlcProcess
! attribute,
!
! The object creates an option file $pwrp_exe/plc_'nodename'_'busnumber'_'plcprocess'.opt
! with options that is added to the link command. If other requirements are
! needed in this file than the BuildOptions object offers, the file can be
! edited and handled manually if no BuildOptions object is present.
......@@ -70,6 +75,15 @@ SObject pwrb:Class
Attr StructName = "BuildOptions"
EndBody
!/**
! Name of PlcProcess object for the executable that these options
! are specifications for. Only the last name segment should be stated.
!*/
Object PlcProcess $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$String32"
EndBody
EndObject
!/**
! System archives and system modules.
!*/
Object SystemModules $Attribute 1
......
......@@ -75,6 +75,11 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object CpuMask $Attribute 15
Body SysBody
Attr TypeRef = "pwrs:Type-$Mask"
EndBody
EndObject
Object BootVersion $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
......
......@@ -121,7 +121,7 @@ void wb_build::node( char *nodename, void *volumelist, int volumecnt)
for ( int i = 0; i < volumecnt; i++) {
if ( cdh_NoCaseStrcmp( nodename, vlist[i].p1) == 0) {
if ( bussid == -1) {
char systemname[80], systemgroup[80], pname[80];
char systemname[80], systemgroup[80];
pwr_tVid *vl;
pwr_tString40 *vnl;
int vcnt;
......@@ -137,7 +137,7 @@ void wb_build::node( char *nodename, void *volumelist, int volumecnt)
cdh_ToLower( fname, fname);
dcli_translate_filename( fname, fname);
status = lfu_ReadBootFile( fname, &btime, systemname, systemgroup, &vl, &vnl,
&vcnt, pname);
&vcnt, 0, 0);
if ( EVEN(status)) {
rebuild = 1;
}
......
This diff is collapsed.
......@@ -133,11 +133,17 @@ typedef struct {
typedef struct {
pwr_tObjid objdid;
pwr_tObjid plcproc_oid;
float scantime;
unsigned long prio;
char name[120];
pwr_tOName name;
} gcg_t_threadlist;
typedef struct {
pwr_tObjid oid;
pwr_tOName name;
} gcg_t_plcproclist;
typedef struct {
pwr_tObjid objdid;
char prefix;
......@@ -326,6 +332,16 @@ int gcg_comp_volume(
ldh_tSesContext ldhses
);
pwr_tStatus gcg_read_volume_plclist(
pwr_tVolumeId volid,
unsigned long *plc_count,
gcg_t_plclist **plclist,
unsigned long *thread_count,
gcg_t_threadlist **threadlist,
unsigned long *plcproc_count,
gcg_t_plcproclist **plcproclist
);
#ifdef __cplusplus
}
#endif
......
This diff is collapsed.
......@@ -115,7 +115,8 @@ pwr_tStatus lfu_ReadBootFile( char *filename,
pwr_tVolumeId **vollist,
pwr_tString40 **volnamelist,
int *volcount,
char *plc_name);
pwr_tString80 **plclist,
int *plccount);
pwr_tStatus lfu_ReadSysObjectFile( char *SystemName,
char *SystemGroup);
......@@ -136,8 +137,9 @@ pwr_tStatus lfu_GetVolumeCnf( char *name, pwr_tVid *vid, pwr_tCid *cid, ldh_eVol
pwr_tStatus lfu_ParseDbmsServer( char *server, char *user, char *passw,
unsigned int *port, char *host);
pwr_tStatus lfu_check_appl_file( char *nodename, int bus_number);
pwr_tStatus lfu_check_opt_file( char *nodename, int bus_number, pwr_mOpSys opsys);
pwr_tStatus lfu_check_appl_file( ldh_tSesContext ldhses,
char *nodename, int bus_number);
pwr_tStatus lfu_check_opt_file( ldh_tSesContext ldhses, char *nodename, int bus_number, pwr_mOpSys opsys);
#ifdef __cplusplus
}
......
......@@ -176,7 +176,8 @@ void wb_pkg::readConfig()
pwr_tVolumeId *vollist;
pwr_tString40 *volnamelist;
int volcount;
char plcname[80];
pwr_tString80 *plclist;
int plccount;
char systemname[80];
char systemgroup[80];
pwr_tTime date;
......@@ -199,12 +200,12 @@ void wb_pkg::readConfig()
// Read bootfile, get plc and volumes
sts = lfu_ReadBootFile( fname, &date, systemname,
systemgroup, &vollist, &volnamelist, &volcount, plcname);
systemgroup, &vollist, &volnamelist, &volcount, &plclist, &plccount);
if ( EVEN(sts))
throw wb_error_str("Bootfile is corrupt");
// Add plc
if ( plcname[0] != 0) {
for ( int j = 0; j < plccount; j++) {
pwr_tFileName dir;
if ( n.opsys() == pwr_mOpSys_CustomBuild &&
......@@ -212,7 +213,7 @@ void wb_pkg::readConfig()
sprintf( dir, "$pwrp_root/bld/%s/exe/", n.customPlatform());
else
sprintf( dir, "$pwrp_root/bld/%s/exe/", cdh_OpSysToStr( n.opsys()));
sprintf( fname, "%s%s", dir, plcname);
sprintf( fname, "%s%s", dir, plclist[j]);
sprintf( dir, "$pwrp_exe/");
pkg_pattern pplc( fname, dir, 'W');
n.push_back( pplc);
......
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