Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
4bec0202
Commit
4bec0202
authored
Apr 20, 2004
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Termination event from rt_ini
parent
032f57ba
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
762 additions
and
46 deletions
+762
-46
java/exe/jpwr_rt_gdh/src/jpwr_rt_mh.c
java/exe/jpwr_rt_gdh/src/jpwr_rt_mh.c
+1
-4
java/exe/jpwr_rt_gdh/src/jpwr_rt_qcom.c
java/exe/jpwr_rt_gdh/src/jpwr_rt_qcom.c
+166
-2
java/exe/jpwr_rt_gdh/src/jpwr_rt_qcom.h
java/exe/jpwr_rt_gdh/src/jpwr_rt_qcom.h
+20
-4
java/jpwr/rt/src/GdhServer.java
java/jpwr/rt/src/GdhServer.java
+31
-2
java/jpwr/rt/src/MhServer.java
java/jpwr/rt/src/MhServer.java
+50
-2
java/jpwr/rt/src/Qcom.java
java/jpwr/rt/src/Qcom.java
+2
-0
src/exe/rt_bck/src/rt_bck.c
src/exe/rt_bck/src/rt_bck.c
+21
-2
src/exe/rt_elog/src/os_linux/rt_elog.c
src/exe/rt_elog/src/os_linux/rt_elog.c
+36
-1
src/exe/rt_fast/src/rt_fast.h
src/exe/rt_fast/src/rt_fast.h
+2
-0
src/exe/rt_ini/src/ini.c
src/exe/rt_ini/src/ini.c
+23
-0
src/exe/rt_ini/src/ini.h
src/exe/rt_ini/src/ini.h
+1
-0
src/exe/rt_ini/src/rt_ini.c
src/exe/rt_ini/src/rt_ini.c
+34
-2
src/exe/rt_neth_acp/src/rt_neth_acp.c
src/exe/rt_neth_acp/src/rt_neth_acp.c
+31
-2
src/exe/rt_qmon/src/rt_qmon.c
src/exe/rt_qmon/src/rt_qmon.c
+5
-2
src/exp/rt/src/rt_plc_process.c
src/exp/rt/src/rt_plc_process.c
+1
-1
src/jpwr/rt/src/GdhServer.java
src/jpwr/rt/src/GdhServer.java
+31
-2
src/jpwr/rt/src/MhServer.java
src/jpwr/rt/src/MhServer.java
+50
-2
src/jpwr/rt/src/Qcom.java
src/jpwr/rt/src/Qcom.java
+2
-0
src/jpwr/rt/src/os_linux/hw_x86/makefile
src/jpwr/rt/src/os_linux/hw_x86/makefile
+1
-0
src/lib/rt/src/os_linux/rt_errl.c
src/lib/rt/src/os_linux/rt_errl.c
+14
-1
src/lib/rt/src/os_linux/rt_proc.c
src/lib/rt/src/os_linux/rt_proc.c
+16
-10
src/lib/rt/src/os_linux/rt_qos.c
src/lib/rt/src/os_linux/rt_qos.c
+0
-3
src/lib/rt/src/os_linux/rt_semaphore.c
src/lib/rt/src/os_linux/rt_semaphore.c
+2
-2
src/lib/rt/src/rt_errl.h
src/lib/rt/src/rt_errl.h
+4
-0
src/lib/rt/src/rt_gdb.c
src/lib/rt/src/rt_gdb.c
+56
-1
src/lib/rt/src/rt_gdb.h
src/lib/rt/src/rt_gdb.h
+4
-0
src/lib/rt/src/rt_gdh.h
src/lib/rt/src/rt_gdh.h
+8
-0
src/lib/rt/src/rt_qcom.c
src/lib/rt/src/rt_qcom.c
+4
-0
src/lib/rt/src/rt_qdb.c
src/lib/rt/src/rt_qdb.c
+121
-0
src/lib/rt/src/rt_qdb.h
src/lib/rt/src/rt_qdb.h
+1
-0
src/lib/rt/src/rt_thread.c
src/lib/rt/src/rt_thread.c
+24
-1
No files found.
java/exe/jpwr_rt_gdh/src/jpwr_rt_mh.c
View file @
4bec0202
...
...
@@ -33,7 +33,7 @@ JNIEXPORT void JNICALL Java_jpwr_rt_Mh_initIDs
Mh_id
=
(
*
env
)
->
FindClass
(
env
,
"jpwr/rt/Mh"
);
if
(
Mh_id
==
NULL
)
{
printf
(
"
null
"
);
printf
(
"
jpwr_rt_mh.c: couldnt find jpwr/rt/Mh class
\n
"
);
}
//hmta pekare till staticmetoden messReceived
Mh_messReceived_id
=
(
*
env
)
->
GetStaticMethodID
(
env
,
Mh_id
,
"messReceived"
,
...
...
@@ -181,9 +181,6 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Mh_outunitConnect
user
.
oix
=
(
*
env
)
->
CallIntMethod
(
env
,
objid_obj
,
PwrtObjid_getOix
);
user
.
vid
=
(
*
env
)
->
CallIntMethod
(
env
,
objid_obj
,
PwrtObjid_getVid
);
// Wait for mh has flagged initizated qqq vad r detta
mh_UtilWaitForMh
();
//gr connect
sts
=
mh_OutunitConnect
(
user
,
...
...
java/exe/jpwr_rt_gdh/src/jpwr_rt_qcom.c
View file @
4bec0202
...
...
@@ -5,6 +5,12 @@
#include "co_time.h"
#include "co_cdh_msg.h"
#include "rt_qcom_msg.h"
#include "rt_errh.h"
#include "rt_pwr_msg.h"
#include "rt_ini_event.h"
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_createQ
(
JNIEnv
*
env
,
jobject
object
,
jint
qix
,
jint
nid
,
jstring
jname
)
...
...
@@ -34,7 +40,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Qcom_createQ
qid
.
nid
=
nid
;
qcom_CreateQ
(
&
sts
,
&
qid
,
&
attr
,
cstr
);
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
jname
,
cstr
);
printf
(
"Create que, qix %d, nid %d, sts %d
\n
"
,
qid
.
qix
,
qid
.
nid
,
sts
);
//
printf( "Create que, qix %d, nid %d, sts %d\n", qid.qix, qid.nid, sts);
jsts
=
(
jint
)
sts
;
return_obj
=
(
*
env
)
->
NewObject
(
env
,
qcomrCreateQ_id
,
qcomrCreateQ_cid
,
qid
.
qix
,
qid
.
nid
,
jsts
);
...
...
@@ -47,6 +53,164 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Qcom_createQ
return
return_obj
;
}
/*
* Class: jpwr_rt_Qcom
* Method: createIniEventQ
* Signature: ()Ljpwr/rt/QcomrCreateQ;
*/
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_createIniEventQ
(
JNIEnv
*
env
,
jobject
object
,
jstring
jname
)
{
jclass
qcomrCreateQ_id
;
jmethodID
qcomrCreateQ_cid
;
jobject
return_obj
;
jint
jsts
;
qcom_sQid
qid
;
qcom_sQattr
qAttr
;
qcom_sQid
qini
;
int
sts
;
char
*
cstr
;
const
char
*
name
;
qcomrCreateQ_id
=
(
*
env
)
->
FindClass
(
env
,
"jpwr/rt/QcomrCreateQ"
);
qcomrCreateQ_cid
=
(
*
env
)
->
GetMethodID
(
env
,
qcomrCreateQ_id
,
"<init>"
,
"(III)V"
);
name
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jname
,
0
);
cstr
=
(
char
*
)
name
;
//printf("%s\n", cstr);
// Create a queue to receive stop and restart events
if
(
!
qcom_Init
(
&
sts
,
0
,
cstr
))
{
errh_Fatal
(
"qcom_Init, %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
sts
);
}
qAttr
.
type
=
qcom_eQtype_private
;
qAttr
.
quota
=
100
;
if
(
!
qcom_CreateQ
(
&
sts
,
&
qid
,
&
qAttr
,
cstr
))
{
errh_Fatal
(
"qcom_CreateQ, %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
sts
);
}
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
jname
,
cstr
);
//printf( "Create que, qix %d, nid %d, sts %d\n", qid.qix, qid.nid, sts);
jsts
=
(
jint
)
sts
;
return_obj
=
(
*
env
)
->
NewObject
(
env
,
qcomrCreateQ_id
,
qcomrCreateQ_cid
,
qid
.
qix
,
qid
.
nid
,
jsts
);
qini
=
qcom_cQini
;
if
(
!
qcom_Bind
(
&
sts
,
&
qid
,
&
qini
))
{
errh_Fatal
(
"qcom_Bind(Qini), %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
-
1
);
}
return
return_obj
;
}
/*
* Class: jpwr_rt_Qcom
* Method: getIniEvent
* Signature: (III)Ljpwr/rt/QcomrGetIniEvent;
*/
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_getIniEvent
(
JNIEnv
*
env
,
jobject
object
,
jint
qix
,
jint
nid
,
jint
timeoutTime
)
{
jclass
qcomrGetIniEvent_id
;
jmethodID
qcomrGetIniEvent_cid
;
jobject
return_obj
;
jint
jsts
;
jboolean
jterminate
=
FALSE
;
jboolean
jswapInit
=
FALSE
;
jboolean
jswapDone
=
FALSE
;
jboolean
jtimeout
=
FALSE
;
qcom_sQid
qid
;
int
sts
;
int
tmo
=
timeoutTime
;
pwr_tBoolean
terminate
=
FALSE
;
pwr_tBoolean
swapInit
=
FALSE
;
pwr_tBoolean
swapDone
=
FALSE
;
pwr_tBoolean
timeout
=
FALSE
;
char
mp
[
2000
];
qcom_sGet
get
;
ini_mEvent
new_event
;
qcom_sEvent
*
ep
;
qcomrGetIniEvent_id
=
(
*
env
)
->
FindClass
(
env
,
"jpwr/rt/QcomrGetIniEvent"
);
qcomrGetIniEvent_cid
=
(
*
env
)
->
GetMethodID
(
env
,
qcomrGetIniEvent_id
,
"<init>"
,
"(ZZZZI)V"
);
qid
.
qix
=
qix
;
qid
.
nid
=
nid
;
get
.
maxSize
=
sizeof
(
mp
);
get
.
data
=
mp
;
qcom_Get
(
&
sts
,
&
qid
,
&
get
,
tmo
);
if
(
sts
==
QCOM__TMO
||
sts
==
QCOM__QEMPTY
)
{
timeout
=
TRUE
;
}
else
{
ep
=
(
qcom_sEvent
*
)
get
.
data
;
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
swapInit
)
{
errh_SetStatus
(
PWR__APPLRESTART
);
swapInit
=
TRUE
;
}
else
if
(
new_event
.
b
.
swapDone
)
{
swapDone
=
TRUE
;
errh_SetStatus
(
PWR__ARUN
);
}
else
if
(
new_event
.
b
.
terminate
)
{
terminate
=
TRUE
;
}
}
jsts
=
(
jint
)
1
;
jterminate
=
(
jboolean
)
terminate
;
jswapInit
=
(
jboolean
)
swapInit
;
jswapDone
=
(
jboolean
)
swapDone
;
jtimeout
=
(
jboolean
)
timeout
;
return_obj
=
(
*
env
)
->
NewObject
(
env
,
qcomrGetIniEvent_id
,
qcomrGetIniEvent_cid
,
jterminate
,
jswapInit
,
jswapDone
,
jtimeout
,
jsts
);
return
return_obj
;
}
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_getString
(
JNIEnv
*
env
,
jobject
object
,
jint
qix
,
jint
nid
)
{
...
...
@@ -71,7 +235,7 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Qcom_getString
qcom_Get
(
&
sts
,
&
qid
,
&
get
,
0
);
if
(
ODD
(
sts
))
{
printf
(
"Qcom_get: Received data: %s
\n
"
,
(
char
*
)
get
.
data
);
//
printf("Qcom_get: Received data: %s\n", (char *)get.data);
jdata
=
(
*
env
)
->
NewStringUTF
(
env
,
(
char
*
)
get
.
data
);
...
...
java/exe/jpwr_rt_gdh/src/jpwr_rt_qcom.h
View file @
4bec0202
...
...
@@ -17,11 +17,19 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Qcom_createQ
/*
* Class: jpwr_rt_Qcom
* Method:
getString
* Signature: (
II)Ljpwr/rt/CdhrString
;
* Method:
createIniEventQ
* Signature: (
Ljava/lang/String;)Ljpwr/rt/QcomrCreateQ
;
*/
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_getString
(
JNIEnv
*
,
jobject
,
jint
,
jint
);
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_createIniEventQ
(
JNIEnv
*
,
jobject
,
jstring
);
/*
* Class: jpwr_rt_Qcom
* Method: getIniEvent
* Signature: (III)Ljpwr/rt/QcomrGetIniEvent;
*/
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_getIniEvent
(
JNIEnv
*
,
jobject
,
jint
,
jint
,
jint
);
/*
* Class: jpwr_rt_Qcom
...
...
@@ -31,6 +39,14 @@ JNIEXPORT jobject JNICALL Java_jpwr_rt_Qcom_getString
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_putString
(
JNIEnv
*
,
jobject
,
jint
,
jint
,
jstring
);
/*
* Class: jpwr_rt_Qcom
* Method: getString
* Signature: (II)Ljpwr/rt/CdhrString;
*/
JNIEXPORT
jobject
JNICALL
Java_jpwr_rt_Qcom_getString
(
JNIEnv
*
,
jobject
,
jint
,
jint
);
#ifdef __cplusplus
}
#endif
...
...
java/jpwr/rt/src/GdhServer.java
View file @
4bec0202
...
...
@@ -129,6 +129,7 @@ public class GdhServer
GdhServer
gdhServer
=
new
GdhServer
();
gdhServer
.
openServerSocket
();
System
.
out
.
println
(
"GdhServer exiting"
);
System
.
exit
(
0
);
}
...
...
@@ -206,11 +207,12 @@ public class GdhServer
try
{
serverSocket
=
new
ServerSocket
(
PORT
);
serverSocket
.
setSoTimeout
(
1000
);
}
catch
(
IOException
e
)
{
errh
.
fatal
(
"Could not listen on port "
+
PORT
);
System
.
exit
(
1
)
;
return
;
}
gdh
=
new
Gdh
((
Object
)
null
);
...
...
@@ -225,7 +227,16 @@ public class GdhServer
}
errh
.
setStatus
(
Errh
.
PWR__SRUN
);
Qcom
qcom
=
new
Qcom
();
QcomrCreateQ
qque
=
qcom
.
createIniEventQ
(
"GdhServer"
);
if
(
qque
.
evenSts
())
{
System
.
out
.
println
(
"Gdhser"
);
errh
.
fatal
(
"GdhSever couldn create EventQue"
);
return
;
}
QcomrGetIniEvent
qrGetIniEv
;
while
(
true
)
{
Socket
cliSocket
=
null
;
...
...
@@ -235,10 +246,28 @@ public class GdhServer
cliSocket
=
serverSocket
.
accept
();
}
catch
(
InterruptedIOException
e
)
{
qrGetIniEv
=
qcom
.
getIniEvent
(
qque
.
qix
,
qque
.
nid
,
0
);
if
(
qrGetIniEv
.
timeout
)
continue
;
else
if
(
qrGetIniEv
.
terminate
)
{
System
.
out
.
println
(
"GdhServer received killmess from QCom"
);
return
;
}
else
{
//Do nothing for the moment
//But in the future we should reinitialize if swap
continue
;
}
}
catch
(
IOException
e
)
{
errh
.
error
(
"Accept failed."
);
// System.exit(1);
continue
;
}
if
(
threadCount
<=
maxConnections
)
...
...
java/jpwr/rt/src/MhServer.java
View file @
4bec0202
...
...
@@ -69,7 +69,18 @@ public class MhServer
MhServer
mhServer
=
new
MhServer
();
mhServer
.
openServerSocket
();
for
(
int
i
=
0
;
i
<
mhServer
.
mhThread
.
length
;
i
++)
{
mhServer
.
mhThread
[
i
]
=
null
;
}
try
{
mhServer
.
finalize
();
}
catch
(
Throwable
e
)
{
}
mhServer
=
null
;
System
.
out
.
println
(
"MhServer exiting"
);
System
.
exit
(
0
);
}
...
...
@@ -131,6 +142,7 @@ public class MhServer
cdhrMaxAlarms
=
gdh
.
getObjectInfoInt
(
maxAlarmsAttr
);
cdhrMaxEvents
=
gdh
.
getObjectInfoInt
(
maxEventsAttr
);
cdhrMaxCon
=
gdh
.
getObjectInfoInt
(
maxConAttr
);
System
.
out
.
println
(
"MaxNoOfAlarms: "
+
cdhrStringUser
.
str
+
" "
+
cdhrMaxAlarms
.
value
+
" "
+
cdhrMaxAlarms
.
evenSts
());
if
(
cdhrMaxCon
.
evenSts
())
{
return
cdhrMaxCon
.
getSts
();
...
...
@@ -184,7 +196,9 @@ public class MhServer
try
{
serverSocket
=
new
ServerSocket
(
PORT
);
serverSocket
.
setSoTimeout
(
1000
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"IOException i openServerSocket"
);
...
...
@@ -217,13 +231,25 @@ public class MhServer
errh
.
setStatus
(
Errh
.
PWR__SRVTERM
);
return
;
}
MhSendThread
mhSendThread
=
new
MhSendThread
(
mh
);
errh
.
setStatus
(
Errh
.
PWR__SRUN
);
Qcom
qcom
=
new
Qcom
();
QcomrCreateQ
qque
=
qcom
.
createIniEventQ
(
"MhServer"
);
if
(
qque
.
evenSts
())
{
System
.
out
.
println
(
"MH:Error during qreateque"
);
errh
.
fatal
(
"MH:Error during qcom.createIniEventQ"
);
return
;
}
QcomrGetIniEvent
qrGetIniEv
;
while
(
keepRunning
)
{
Socket
cliSocket
=
null
;
...
...
@@ -235,11 +261,33 @@ public class MhServer
}
cliSocket
=
serverSocket
.
accept
();
}
catch
(
InterruptedIOException
e
)
{
qrGetIniEv
=
qcom
.
getIniEvent
(
qque
.
qix
,
qque
.
nid
,
0
);
if
(
qrGetIniEv
.
timeout
)
{
//do nothing
continue
;
}
else
if
(
qrGetIniEv
.
terminate
)
{
//Time to die
System
.
out
.
println
(
"MhServer received killmess from QCom"
);
return
;
}
else
{
//All other messages is qurrently ignored
//But perhaps we should reinitialize when we get
//swapdone
continue
;
}
}
catch
(
IOException
e
)
{
errh
.
error
(
"Accept failed."
);
// System.exit(1);
continue
;
}
if
(
log
)
...
...
java/jpwr/rt/src/Qcom.java
View file @
4bec0202
...
...
@@ -21,6 +21,8 @@ public class Qcom {
}
public
native
QcomrCreateQ
createQ
(
int
qix
,
int
nid
,
String
name
);
public
native
QcomrCreateQ
createIniEventQ
(
String
name
);
public
native
QcomrGetIniEvent
getIniEvent
(
int
qix
,
int
nid
,
int
timeoutTime
);
private
native
PwrtStatus
putString
(
int
qix
,
int
nid
,
String
data
);
public
native
CdhrString
getString
(
int
qix
,
int
nid
);
}
src/exe/rt_bck/src/rt_bck.c
View file @
4bec0202
...
...
@@ -57,6 +57,9 @@
#include "co_dcli.h"
#include "rt_pwr_msg.h"
#include "rt_aproc.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
#define check4a(sts,str) if((sts)==-1)perror(str)
...
...
@@ -1353,6 +1356,7 @@ int main ()
pwr_tStatus
sts
;
pwr_tInt32
sts4a
;
pwr_tUInt32
c
;
qcom_sQid
my_q
=
qcom_cNQid
;
errh_Init
(
"pwr_bck"
,
errh_eAnix_bck
);
errh_SetStatus
(
PWR__SRVSTARTUP
);
...
...
@@ -1370,6 +1374,18 @@ int main ()
}
errh_SetStatus
(
PWR__SRUN
);
if
(
!
qcom_Init
(
&
sts
,
NULL
,
"pwr_bck"
))
{
errh_Fatal
(
"qcom_Init, %m"
,
sts
);
errh_SetStatus
(
PWR__SRVTERM
);
exit
(
sts
);
}
if
(
!
qcom_CreateQ
(
&
sts
,
&
my_q
,
NULL
,
"events"
))
{
errh_Fatal
(
"qcom_CreateQ, %m"
,
sts
);
errh_SetStatus
(
PWR__SRVTERM
);
exit
(
sts
);
}
for
(;;)
{
#ifdef OS_ELN
ker
$
clear_event
(
NULL
,
bck_forced_activation
);
...
...
@@ -1380,8 +1396,11 @@ int main ()
sts
=
sys
$
waitfr
(
BCK_ACTIVATE
);
if
(
EVEN
(
sts
))
lib
$
signal
(
sts
);
/* BUG */
#else
while
(
1
)
pause
();
while
(
1
)
{
qcom_WaitAnd
(
&
sts
,
&
my_q
,
&
qcom_cQini
,
ini_mEvent_terminate
,
qcom_cTmoEternal
);
// pause();
exit
(
0
);
}
#endif
/* We were activated from the outer world. Trigger */
...
...
src/exe/rt_elog/src/os_linux/rt_elog.c
View file @
4bec0202
...
...
@@ -9,6 +9,9 @@
#include "twolist.h"
#include "rt_aproc.h"
#include "rt_pwr_msg.h"
#include "rt_ini_event.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#define Log_Error(a, b) errh_Error("%s\n%m",b, a)
#define Log(b) errh_Info(b)
...
...
@@ -46,7 +49,9 @@ int
main
()
{
pwr_tUInt32
sts
;
pwr_tObjid
oid
;
pwr_tObjid
oid
;
qcom_sQid
my_q
=
qcom_cNQid
;
qcom_sGet
get
;
pwr_tBoolean
firstTime
=
TRUE
;
pwr_tUInt32
nrOfEvents
=
0
;
...
...
@@ -62,6 +67,19 @@ main ()
If_Error_Log_Exit
(
sts
,
"gdh_Init"
);
Init
();
/* Create queue for receival of events */
if
(
!
qcom_CreateQ
(
&
sts
,
&
my_q
,
NULL
,
"events"
))
{
errh_Fatal
(
"qcom_CreateQ, %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
sts
);
}
if
(
!
qcom_Bind
(
&
sts
,
&
my_q
,
&
qcom_cQini
))
{
errh_Fatal
(
"qcom_Bind(Qini), %m"
,
sts
);
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
-
1
);
}
oid
.
vid
=
lHelCB
.
Nid
;
oid
.
oix
=
pwr_cNVolumeId
;
...
...
@@ -91,6 +109,23 @@ main ()
Log_Error
(
sts
,
"mh_OutunitReceive"
);
Store
(
&
firstTime
,
&
nrOfEvents
,
&
nrOfKeys
);
get
.
data
=
NULL
;
qcom_Get
(
&
sts
,
&
my_q
,
&
get
,
0
);
if
(
sts
!=
QCOM__TMO
&&
sts
!=
QCOM__QEMPTY
)
{
if
(
get
.
type
.
b
==
qcom_eBtype_event
)
{
qcom_sEvent
*
ep
=
(
qcom_sEvent
*
)
get
.
data
;
ini_mEvent
new_event
;
if
(
get
.
type
.
s
==
qcom_cIini
)
{
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
terminate
)
{
errh_SetStatus
(
PWR__APPLTERM
);
exit
(
0
);
}
}
}
qcom_Free
(
&
sts
,
get
.
data
);
}
aproc_TimeStamp
();
}
}
...
...
src/exe/rt_fast/src/rt_fast.h
View file @
4bec0202
#ifndef rt_dsfast_h
#define rt_dsfast_h
using
namespace
std
;
#include <string.h>
#include <vector>
extern
"C"
{
...
...
src/exe/rt_ini/src/ini.c
View file @
4bec0202
...
...
@@ -1855,6 +1855,29 @@ ini_ProcStart (
errh_LogError
(
&
cp
->
log
,
"Error starting %s, %m"
,
pp
->
id
,
*
sts
);
}
void
ini_ProcPrio
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
ini_sProc
*
pp
)
{
char
set
[
100
];
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
if
(
pp
->
flags
.
b
.
running
)
return
;
if
(
pp
->
flags
.
b
.
run
)
{
#if defined(OS_LINUX)
sprintf
(
set
,
"rt_prio -rp %d %d"
,
pp
->
proc
.
p_prio
,
pp
->
proc
.
pid
);
system
(
set
);
#endif
}
}
void
ini_ProcIter
(
pwr_tStatus
*
status
,
...
...
src/exe/rt_ini/src/ini.h
View file @
4bec0202
...
...
@@ -182,6 +182,7 @@ void ini_ProcIter (pwr_tStatus*, ini_sContext*, 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
*
);
void
ini_ProcPrio
(
pwr_tStatus
*
,
ini_sContext
*
,
ini_sProc
*
);
void
ini_ProcTable
(
pwr_tStatus
*
,
ini_sContext
*
);
void
ini_ProcWait
(
pwr_tStatus
*
,
ini_sContext
*
);
pwr_tBoolean
ini_RebuildNode
(
pwr_tStatus
*
,
ini_sContext
*
);
...
...
src/exe/rt_ini/src/rt_ini.c
View file @
4bec0202
...
...
@@ -182,6 +182,7 @@ start (
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
);
net_Connect
(
&
sts
,
&
gdbroot
->
my_aid
,
&
gdbroot
->
my_qid
,
NULL
,
"pwr_ini"
);
/*if (!qcom_Init(&sts, 0)) {*/
...
...
@@ -435,7 +436,38 @@ terminate (
qcom_SignalOr
(
&
sts
,
&
qcom_cQini
,
ini_mEvent_oldPlcStop
);
qcom_WaitAnd
(
&
sts
,
&
cp
->
eventQ
,
&
qcom_cQini
,
ini_mEvent_oldPlcStopDone
,
qcom_cTmoEternal
);
return
sts
;
qcom_Exit
(
NULL
);
/* Kill programs which until now doesn't handle qcom */
/*
for (pp = lst_Succ(NULL, &cp->proc_lh, &pl); pp != NULL; pp = lst_Succ(NULL, pl, &pl)) {
if (strncmp("pwr_webmonmh", pp->proc.name, 12) == 0) {
kill(pp->proc.pid, SIGKILL);
}
else if (strncmp("pwr_webmon", pp->proc.name, 10) == 0) {
kill(pp->proc.pid, SIGKILL);
}
}
*/
/* Now sleep for a while */
sleep
(
2
);
/* Unlink shared memory and semaphores */
gdb_UnlinkDb
();
qdb_UnlinkDb
();
/* Destroy message handler semaphore */
mh_UtilDestroyEvent
();
#if defined(OS_LINUX)
/* Unlink errlog mwessage queue */
errl_Unlink
();
#endif
exit
(
1
);
}
static
int
...
...
@@ -904,7 +936,7 @@ static void ini_errl_cb( void *userdata, char *str, char severity, pwr_tStatus s
if
(
anix
==
0
||
!
cp
->
np
)
return
;
if
(
anix
>=
sizeof
(
cp
->
np
->
ProcStatus
)
/
sizeof
(
cp
->
np
->
ProcStatus
[
0
]))
{
printf
(
"Init: undefind anix %d
\n
"
,
anix
);
printf
(
"Init: undefin
e
d anix %d
\n
"
,
anix
);
return
;
}
...
...
src/exe/rt_neth_acp/src/rt_neth_acp.c
View file @
4bec0202
...
...
@@ -29,8 +29,9 @@
#include "rt_subc.h"
#include "rt_net.h"
#include "rt_pwr_msg.h"
#include "rt_ini_event.h"
static
void
event
(
qcom_sGet
*
get
);
static
void
init
(
qcom_sQid
*
qid
);
static
void
lockMountServers
(
gdb_sNode
*
np
);
static
gdb_sNode
*
node
(
net_sMessage
*
mp
);
...
...
@@ -126,6 +127,12 @@ init (
}
*
myQid
=
qcom_cQnacp
;
if
(
!
qcom_Bind
(
&
sts
,
myQid
,
&
qcom_cQini
))
{
errh_Fatal
(
"qcom_Bind, %m"
,
sts
);
errh_SetStatus
(
PWR__SRVTERM
);
exit
(
-
1
);
}
/* Activate all subscriptions that were requested before we started! */
gdb_ScopeLock
{
...
...
@@ -158,7 +165,12 @@ receive (
continue
;
}
if
(
get
->
type
.
b
!=
net_cMsgClass
)
{
if
(
get
->
type
.
b
==
qcom_eBtype_event
)
{
event
(
get
);
qcom_Free
(
&
sts
,
mp
);
}
else
if
(
get
->
type
.
b
!=
net_cMsgClass
)
{
errh_Error
(
"Received bad message, type: <%d>, subtype: <%d>"
,
get
->
type
.
b
,
get
->
type
.
s
);
qcom_Free
(
&
sts
,
mp
);
continue
;
...
...
@@ -168,6 +180,23 @@ receive (
}
}
static
void
event
(
qcom_sGet
*
get
)
{
qcom_sEvent
*
ep
=
(
qcom_sEvent
*
)
get
->
data
;
ini_mEvent
new_event
;
if
(
get
->
type
.
s
!=
qcom_cIini
)
return
;
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
terminate
)
{
exit
(
0
);
}
}
/* Check message node identity and return pointer to node. */
static
gdb_sNode
*
...
...
src/exe/rt_qmon/src/rt_qmon.c
View file @
4bec0202
...
...
@@ -316,6 +316,9 @@ main (int argc, char *argv[])
qcom_sQid
qid
=
qdb_cQexport
;
qcom_sQid
neth_qid
;
qcom_sQid
my_q
=
qcom_cNQid
;
/* Vnta en stund ... */
// sleep(5);
errh_Init
(
"pwr_qmon"
,
errh_eAnix_qmon
);
errh_SetStatus
(
PWR__SRVSTARTUP
);
...
...
@@ -394,9 +397,9 @@ main (int argc, char *argv[])
errh_SetStatus
(
PWR__SRUN
);
qcom_WaitAnd
(
&
sts
,
&
my_q
,
&
qcom_cQini
,
ini_mEvent_terminate
,
qcom_cTmoEternal
);
//
qcom_WaitAnd(&sts, &my_q, &qcom_cQini, ini_mEvent_terminate, qcom_cTmoEternal);
//
sts = thread_Wait(NULL); /* Wait forever */
sts
=
thread_Wait
(
NULL
);
/* Wait forever */
errh_SetStatus
(
PWR__SRVTERM
);
errh_Info
(
"pwr_qmon says: I will soon die, %m"
,
sts
);
...
...
src/exp/rt/src/rt_plc_process.c
View file @
4bec0202
...
...
@@ -132,7 +132,7 @@ int main (
qcom_SignalOr
(
&
sts
,
&
qcom_cQini
,
ini_mEvent_newPlcInitDone
);
qcom_WaitAnd
(
&
sts
,
&
pp
->
eventQ
,
&
qcom_cQini
,
ini_mEvent_newPlcStart
,
qcom_cTmoEternal
);
proc_SetPriority
(
pp
->
PlcProcess
->
Prio
);
//
proc_SetPriority(pp->PlcProcess->Prio);
set_values
(
pp
);
start_threads
(
pp
);
time_Uptime
(
&
sts
,
&
pp
->
PlcProcess
->
StartTime
,
NULL
);
...
...
src/jpwr/rt/src/GdhServer.java
View file @
4bec0202
...
...
@@ -129,6 +129,7 @@ public class GdhServer
GdhServer
gdhServer
=
new
GdhServer
();
gdhServer
.
openServerSocket
();
System
.
out
.
println
(
"GdhServer exiting"
);
System
.
exit
(
0
);
}
...
...
@@ -206,11 +207,12 @@ public class GdhServer
try
{
serverSocket
=
new
ServerSocket
(
PORT
);
serverSocket
.
setSoTimeout
(
1000
);
}
catch
(
IOException
e
)
{
errh
.
fatal
(
"Could not listen on port "
+
PORT
);
System
.
exit
(
1
)
;
return
;
}
gdh
=
new
Gdh
((
Object
)
null
);
...
...
@@ -225,7 +227,16 @@ public class GdhServer
}
errh
.
setStatus
(
Errh
.
PWR__SRUN
);
Qcom
qcom
=
new
Qcom
();
QcomrCreateQ
qque
=
qcom
.
createIniEventQ
(
"GdhServer"
);
if
(
qque
.
evenSts
())
{
System
.
out
.
println
(
"Gdhser"
);
errh
.
fatal
(
"GdhSever couldn create EventQue"
);
return
;
}
QcomrGetIniEvent
qrGetIniEv
;
while
(
true
)
{
Socket
cliSocket
=
null
;
...
...
@@ -235,10 +246,28 @@ public class GdhServer
cliSocket
=
serverSocket
.
accept
();
}
catch
(
InterruptedIOException
e
)
{
qrGetIniEv
=
qcom
.
getIniEvent
(
qque
.
qix
,
qque
.
nid
,
0
);
if
(
qrGetIniEv
.
timeout
)
continue
;
else
if
(
qrGetIniEv
.
terminate
)
{
System
.
out
.
println
(
"GdhServer received killmess from QCom"
);
return
;
}
else
{
//Do nothing for the moment
//But in the future we should reinitialize if swap
continue
;
}
}
catch
(
IOException
e
)
{
errh
.
error
(
"Accept failed."
);
// System.exit(1);
continue
;
}
if
(
threadCount
<=
maxConnections
)
...
...
src/jpwr/rt/src/MhServer.java
View file @
4bec0202
...
...
@@ -69,7 +69,18 @@ public class MhServer
MhServer
mhServer
=
new
MhServer
();
mhServer
.
openServerSocket
();
for
(
int
i
=
0
;
i
<
mhServer
.
mhThread
.
length
;
i
++)
{
mhServer
.
mhThread
[
i
]
=
null
;
}
try
{
mhServer
.
finalize
();
}
catch
(
Throwable
e
)
{
}
mhServer
=
null
;
System
.
out
.
println
(
"MhServer exiting"
);
System
.
exit
(
0
);
}
...
...
@@ -131,6 +142,7 @@ public class MhServer
cdhrMaxAlarms
=
gdh
.
getObjectInfoInt
(
maxAlarmsAttr
);
cdhrMaxEvents
=
gdh
.
getObjectInfoInt
(
maxEventsAttr
);
cdhrMaxCon
=
gdh
.
getObjectInfoInt
(
maxConAttr
);
System
.
out
.
println
(
"MaxNoOfAlarms: "
+
cdhrStringUser
.
str
+
" "
+
cdhrMaxAlarms
.
value
+
" "
+
cdhrMaxAlarms
.
evenSts
());
if
(
cdhrMaxCon
.
evenSts
())
{
return
cdhrMaxCon
.
getSts
();
...
...
@@ -184,7 +196,9 @@ public class MhServer
try
{
serverSocket
=
new
ServerSocket
(
PORT
);
serverSocket
.
setSoTimeout
(
1000
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"IOException i openServerSocket"
);
...
...
@@ -217,13 +231,25 @@ public class MhServer
errh
.
setStatus
(
Errh
.
PWR__SRVTERM
);
return
;
}
MhSendThread
mhSendThread
=
new
MhSendThread
(
mh
);
errh
.
setStatus
(
Errh
.
PWR__SRUN
);
Qcom
qcom
=
new
Qcom
();
QcomrCreateQ
qque
=
qcom
.
createIniEventQ
(
"MhServer"
);
if
(
qque
.
evenSts
())
{
System
.
out
.
println
(
"MH:Error during qreateque"
);
errh
.
fatal
(
"MH:Error during qcom.createIniEventQ"
);
return
;
}
QcomrGetIniEvent
qrGetIniEv
;
while
(
keepRunning
)
{
Socket
cliSocket
=
null
;
...
...
@@ -235,11 +261,33 @@ public class MhServer
}
cliSocket
=
serverSocket
.
accept
();
}
catch
(
InterruptedIOException
e
)
{
qrGetIniEv
=
qcom
.
getIniEvent
(
qque
.
qix
,
qque
.
nid
,
0
);
if
(
qrGetIniEv
.
timeout
)
{
//do nothing
continue
;
}
else
if
(
qrGetIniEv
.
terminate
)
{
//Time to die
System
.
out
.
println
(
"MhServer received killmess from QCom"
);
return
;
}
else
{
//All other messages is qurrently ignored
//But perhaps we should reinitialize when we get
//swapdone
continue
;
}
}
catch
(
IOException
e
)
{
errh
.
error
(
"Accept failed."
);
// System.exit(1);
continue
;
}
if
(
log
)
...
...
src/jpwr/rt/src/Qcom.java
View file @
4bec0202
...
...
@@ -21,6 +21,8 @@ public class Qcom {
}
public
native
QcomrCreateQ
createQ
(
int
qix
,
int
nid
,
String
name
);
public
native
QcomrCreateQ
createIniEventQ
(
String
name
);
public
native
QcomrGetIniEvent
getIniEvent
(
int
qix
,
int
nid
,
int
timeoutTime
);
private
native
PwrtStatus
putString
(
int
qix
,
int
nid
,
String
data
);
public
native
CdhrString
getString
(
int
qix
,
int
nid
);
}
src/jpwr/rt/src/os_linux/hw_x86/makefile
View file @
4bec0202
...
...
@@ -16,6 +16,7 @@ local_java_sources = \
CliTable.java
\
Cli.java
\
QcomrCreateQ.java
\
QcomrGetIniEvent.java
\
Qcom.java
\
Errh.java
\
RtUtilities.java
\
...
...
src/lib/rt/src/os_linux/rt_errl.c
View file @
4bec0202
...
...
@@ -29,6 +29,7 @@ static mqd_t mqid = (mqd_t)-1;
static
int
logFile
=
-
1
;
static
int
newLogFile
=
1
;
static
int
term
=
-
1
;
static
pthread_t
tid
=
0
;
static
int
yday
=
-
1
;
static
pwr_tBoolean
logToStdout
=
FALSE
;
static
void
(
*
errl_log_cb
)(
void
*
,
char
*
,
char
,
pwr_tStatus
,
int
,
int
)
=
0
;
...
...
@@ -46,7 +47,6 @@ errl_Init (
)
{
pthread_mutexattr_t
mutexattr
;
pthread_t
tid
;
pthread_attr_t
pthreadattr
;
struct
mq_attr
mqattr
;
mode_t
mode
;
...
...
@@ -115,6 +115,19 @@ errl_Init (
return
;
}
void
errl_Unlink
()
{
char
name
[
64
];
char
*
busid
=
getenv
(
pwr_dEnvBusId
);
pthread_cancel
(
tid
);
sprintf
(
name
,
"%s_%s"
,
LOG_QUEUE_NAME
,
busid
?
busid
:
""
);
/* We don't care about return status */
mq_unlink
(
name
);
}
void
errl_SetFile
(
const
char
*
logFileName
)
{
...
...
src/lib/rt/src/os_linux/rt_proc.c
View file @
4bec0202
...
...
@@ -65,18 +65,24 @@ proc_SetPriority (
int
prio
)
{
struct
sched_param
param
;
int
rc
;
// struct sched_param param;
// int rc;
int
pid
;
char
set
[
100
];
pwr_tStatus
sts
=
PROC__SUCCESS
;
rc
=
sched_getparam
((
pid_t
)
0
,
&
param
);
if
(
rc
!=
0
)
return
errno_GetStatus
();
param
.
sched_priority
=
prio
;
rc
=
sched_setscheduler
((
pid_t
)
0
,
SCHED_RR
,
&
param
);
if
(
rc
!=
0
)
return
errno_GetStatus
();
return
sts
;
pid
=
getpid
();
// rc = sched_getparam((pid_t)0, ¶m);
// if (rc != 0)
// return errno_GetStatus();
// param.sched_priority = prio;
// rc = sched_setscheduler((pid_t)0, SCHED_RR, ¶m);
// if (rc != 0)
// return errno_GetStatus();
sprintf
(
set
,
"rt_prio -rp %d %d"
,
prio
,
pid
);
// system(set);
return
sts
;
}
pwr_tStatus
...
...
src/lib/rt/src/os_linux/rt_qos.c
View file @
4bec0202
...
...
@@ -37,7 +37,6 @@ qos_WaitQue (
{
pwr_tDeltaTime
dtime
;
sigset_t
newset
;
sigset_t
oldset
;
siginfo_t
info
;
int
ok
;
pwr_tBoolean
signal
=
FALSE
;
...
...
@@ -52,7 +51,6 @@ qos_WaitQue (
sigemptyset
(
&
newset
);
sigaddset
(
&
newset
,
qdb_cSigMsg
);
sigprocmask
(
SIG_BLOCK
,
&
newset
,
&
oldset
);
// qp->lock.pid = BUILDPID(getpid(), pthread_self());
// I think that each thread has it's own pid in Linux. ML
...
...
@@ -87,7 +85,6 @@ qos_WaitQue (
signal
=
TRUE
;
}
sigprocmask
(
SIG_SETMASK
,
&
oldset
,
NULL
);
return
signal
;
}
...
...
src/lib/rt/src/os_linux/rt_semaphore.c
View file @
4bec0202
...
...
@@ -48,7 +48,7 @@ sem_t *posix_sem_open(const char *name, int oflag, ...)
return
(
sem_t
*
)
-
1
;
}
close
(
fd
);
key
=
ftok
(
name
,
0
);
key
=
ftok
(
name
,
'P'
);
if
(
key
<
0
)
{
return
(
sem_t
*
)
-
1
;
}
...
...
@@ -198,7 +198,7 @@ int posix_sem_trywait(sem_t *sem)
int
posix_sem_unlink
(
const
char
*
name
)
{
int
key
,
semid
;
key
=
ftok
(
name
,
0
);
key
=
ftok
(
name
,
'P'
);
if
(
key
<
0
)
{
return
-
1
;
}
...
...
src/lib/rt/src/rt_errl.h
View file @
4bec0202
...
...
@@ -29,4 +29,8 @@ void errl_Init (const char *termname,
void
errl_SetTerm
(
const
char
*
termname
);
void
errl_SetFile
(
const
char
*
filename
);
#if defined OS_LINUX
void
errl_Unlink
();
#endif
#endif
src/lib/rt/src/rt_gdb.c
View file @
4bec0202
...
...
@@ -20,6 +20,9 @@
#elif defined(OS_LINUX)
# include <sys/file.h>
# include <sys/stat.h>
# include <sys/ipc.h>
# include <sys/shm.h>
# include "rt_semaphore.h"
#endif
#include "pwr.h"
...
...
@@ -244,6 +247,9 @@ unlinkPool(
int
fd
;
int
flags
=
O_RDWR
;
mode_t
mode
=
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
;
key_t
key
;
int
shm_id
;
struct
shmid_ds
ds
;
char
*
str
=
getenv
(
pwr_dEnvBusId
);
char
segname
[
128
];
...
...
@@ -266,11 +272,15 @@ unlinkPool(
#if defined OS_LYNX
shm_unlink
(
segname
);
#else
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
);
unlink
(
segname
);
#endif
for
(
i
=
1
;
TRUE
;
i
++
)
{
sprintf
(
segname
,
"%s%04d_%.3s"
,
name
,
i
,
busid
);
sprintf
(
segname
,
"%
.11
s%04d_%.3s"
,
name
,
i
,
busid
);
#if defined OS_LYNX
fd
=
shm_open
(
segname
,
flags
,
mode
);
#else
...
...
@@ -285,6 +295,10 @@ unlinkPool(
#if defined OS_LYNX
shm_unlink
(
segname
);
#else
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
);
unlink
(
segname
);
#endif
...
...
@@ -796,6 +810,47 @@ gdb_CreateDb (
return
gdbroot
;
}
/* This routine unlinks the object and node database and
removes database lock.
It should only be called by the init program. */
void
gdb_UnlinkDb
()
{
char
segname
[
128
];
char
busid
[
8
];
char
*
str
=
getenv
(
pwr_dEnvBusId
);
key_t
key
;
int
shm_id
;
struct
shmid_ds
ds
;
#if defined OS_LYNX || defined OS_LINUX
/* Unlink pool. */
unlinkPool
(
gdb_cNamePool
);
unlinkPool
(
gdb_cNameRtdb
);
/* Remove database lock. */
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
busid
[
3
]
=
'\0'
;
sprintf
(
segname
,
"%s_%.3s"
,
gdb_cNameDbLock
,
busid
);
#if defined OS_LYNX
shm_unlink
(
segname
);
#else
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
);
posix_sem_unlink
(
segname
);
unlink
(
segname
);
#endif
#endif
}
/* Allocate an object header and initiate
the global part of the header. */
...
...
src/lib/rt/src/rt_gdb.h
View file @
4bec0202
...
...
@@ -1190,6 +1190,10 @@ gdb_CreateDb (
gdb_sInit
*
ip
);
void
gdb_UnlinkDb
(
);
gdb_sObject
*
gdb_LoadObject
(
pwr_tStatus
*
sts
,
...
...
src/lib/rt/src/rt_gdh.h
View file @
4bec0202
...
...
@@ -8,6 +8,11 @@
This include file defines the global datastructures and
data entities in GDH. Also, the GDH entry points are defined. */
#if defined __cplusplus
extern
"C"
{
#endif
/**
*@example gdh_examples.c
*/
...
...
@@ -619,4 +624,7 @@ gdh_SetCache (
/** @} */
/** @} */
#if defined __cplusplus
}
#endif
#endif
src/lib/rt/src/rt_qcom.c
View file @
4bec0202
...
...
@@ -528,6 +528,7 @@ qcom_Init (
FUNCTION_DESCRIPTOR
f_dsc
;
#elif defined OS_LINUX || defined OS_LYNX
struct
sigaction
sa
;
sigset_t
ss
;
#endif
pwr_dStatus
(
sts
,
status
,
QCOM__SUCCESS
);
...
...
@@ -597,6 +598,9 @@ qcom_Init (
sigemptyset
(
&
sa
.
sa_mask
);
sigaction
(
SIGHUP
,
&
sa
,
NULL
);
sigaction
(
SIGINT
,
&
sa
,
NULL
);
sigemptyset
(
&
ss
);
sigaddset
(
&
ss
,
qdb_cSigMsg
);
sigprocmask
(
SIG_BLOCK
,
&
ss
,
NULL
);
#elif defined OS_VMS
atexit
(
exitHandler
);
...
...
src/lib/rt/src/rt_qdb.c
View file @
4bec0202
...
...
@@ -20,6 +20,17 @@
# include <signal.h>
#endif
#if defined (OS_LYNX)
# include <sys/mman.h>
#elif defined(OS_LINUX)
# include <sys/file.h>
# include <sys/stat.h>
# include <sys/ipc.h>
# include <sys/shm.h>
# include "rt_semaphore.h"
#endif
#include <errno.h>
#include "pwr.h"
#include "co_time.h"
...
...
@@ -737,6 +748,116 @@ qdb_CreateDb (
return
qdb
;
}
#if defined OS_LYNX || defined OS_LINUX
/*
* A fix which unlinks all segments for the given name.
*/
static
void
unlinkPool
(
const
char
*
name
){
int
i
;
int
fd
;
int
flags
=
O_RDWR
;
mode_t
mode
=
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
;
key_t
key
;
int
shm_id
;
struct
shmid_ds
ds
;
char
*
str
=
getenv
(
pwr_dEnvBusId
);
char
segname
[
128
];
char
busid
[
8
];
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
busid
[
3
]
=
'\0'
;
sprintf
(
segname
,
"%s_%.3s"
,
name
,
busid
);
#if defined OS_LYNX
fd
=
shm_open
(
segname
,
flags
,
mode
);
#else
fd
=
open
(
segname
,
flags
,
mode
);
#endif
if
(
fd
!=
-
1
)
{
close
(
fd
);
#if defined OS_LYNX
shm_unlink
(
segname
);
#else
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
);
unlink
(
segname
);
#endif
for
(
i
=
1
;
TRUE
;
i
++
)
{
sprintf
(
segname
,
"%.11s%04d_%.3s"
,
name
,
i
,
busid
);
#if defined OS_LYNX
fd
=
shm_open
(
segname
,
flags
,
mode
);
#else
fd
=
open
(
segname
,
flags
,
mode
);
#endif
if
(
fd
==
-
1
)
break
;
close
(
fd
);
#if defined OS_LYNX
shm_unlink
(
segname
);
#else
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
);
unlink
(
segname
);
#endif
}
}
}
#endif
/* This routine unlinks QCOM database and
removes database lock.
It should only be called by the init program. */
void
qdb_UnlinkDb
()
{
char
segname
[
128
];
char
busid
[
8
];
char
*
str
=
getenv
(
pwr_dEnvBusId
);
key_t
key
;
int
shm_id
;
struct
shmid_ds
ds
;
#if defined OS_LYNX || defined OS_LINUX
/* Unlink pool. */
unlinkPool
(
qdb_cNamePool
);
/* Remove database lock. */
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
busid
[
3
]
=
'\0'
;
sprintf
(
segname
,
"%s_%.3s"
,
qdb_cNameDbLock
,
busid
);
#if defined OS_LYNX
shm_unlink
(
segname
);
#else
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
);
posix_sem_unlink
(
segname
);
unlink
(
segname
);
#endif
#endif
}
qdb_sLocal
*
qdb_MapDb
(
pwr_tStatus
*
status
...
...
src/lib/rt/src/rt_qdb.h
View file @
4bec0202
...
...
@@ -728,6 +728,7 @@ qdb_sBuffer* qdb_CopyBuffer (pwr_tStatus*, qdb_sBuffer*);
void
*
qdb_CopyBufferData
(
pwr_tStatus
*
,
qdb_sBuffer
*
,
qcom_sGet
*
);
qdb_sBuffer
*
qdb_DetachBuffer
(
pwr_tStatus
*
,
qdb_sBuffer
*
);
qdb_sLocal
*
qdb_CreateDb
(
pwr_tStatus
*
,
qdb_sInit
*
);
void
qdb_UnlinkDb
();
qdb_sQlock
*
qdb_CreateQlock
(
pwr_tStatus
*
,
qdb_sQue
*
);
void
qdb_DeleteQlock
(
pwr_tStatus
*
,
qdb_sQue
*
);
qdb_sBuffer
*
qdb_Deque
(
pwr_tStatus
*
,
qdb_sQue
*
,
int
);
...
...
src/lib/rt/src/rt_thread.c
View file @
4bec0202
...
...
@@ -575,7 +575,7 @@ thread_SetPrio (
return
ERRNO__SUCCESS
;
}
#elif defined OS_L
INUX || defined OS_L
YNX
#elif defined OS_LYNX
{
struct
sched_param
par
;
pthread_t
id
;
...
...
@@ -590,6 +590,29 @@ thread_SetPrio (
return
errno_Status
(
pthread_setschedparam
(
id
,
SCHED_FIFO
,
&
par
));
}
#elif defined OS_LINUX
{
int
pid
,
policy
;
pthread_t
tid
;
char
set
[
100
];
struct
sched_param
par
;
pwr_tStatus
sts
=
THREAD__SUCCESS
;
/* Set priority and scheduling mechanism for thread. */
/* -f equals SCHED_FIFO */
pid
=
getpid
();
tid
=
pthread_self
();
prio
=
MIN
(
sched_get_priority_max
(
SCHED_FIFO
),
sched_get_priority_min
(
SCHED_FIFO
)
+
prio
);
// sprintf(set, "/home/rk8584/sched/nptlrt -fp %i %i", prio, tid);
// system(set);
par
.
sched_priority
=
prio
;
pthread_setschedparam
(
tid
,
SCHED_FIFO
,
&
par
);
pthread_getschedparam
(
tid
,
&
policy
,
&
par
);
errh_Info
(
"My policy: %s, prio: %d"
,
policy
!=
SCHED_OTHER
?
"RT"
:
"OTHER"
,
par
.
sched_priority
);
return
sts
;
}
#else
# error Not defined for this platform !
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment