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
0dfc7602
Commit
0dfc7602
authored
Jan 25, 2008
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NMpsCell lock added
parent
43421720
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
29 deletions
+187
-29
nmps/lib/nmps/src/nmps_appl.c
nmps/lib/nmps/src/nmps_appl.c
+8
-1
nmps/lib/nmps/src/nmps_plc.c
nmps/lib/nmps/src/nmps_plc.c
+66
-28
src/lib/rt/src/rt_nmps_lock.c
src/lib/rt/src/rt_nmps_lock.c
+77
-0
src/lib/rt/src/rt_nmps_lock.h
src/lib/rt/src/rt_nmps_lock.h
+36
-0
No files found.
nmps/lib/nmps/src/nmps_appl.c
View file @
0dfc7602
/*
* Proview $Id: nmps_appl.c,v 1.
2 2006-06-08 04:28:12
claes Exp $
* Proview $Id: nmps_appl.c,v 1.
3 2008-01-25 14:35:29
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -57,6 +57,7 @@
#include "co_cdh.h"
#include "rt_gdh.h"
#include "rt_errh.h"
#include "rt_nmps_lock.h"
#include "rt_gdh_msg.h"
#include "rt_hash_msg.h"
#include "rs_nmps_msg.h"
...
...
@@ -113,6 +114,7 @@ typedef struct nmpsappl_s_basectx {
static
nmpsappl_t_basectx
nmpsappl_basectx
=
0
;
/*_Local functions________________________________________________________*/
static
pwr_tStatus
nmpsappl_data_db_create
(
...
...
@@ -411,6 +413,9 @@ nmpsappl_MirrorInit(
(
nmpsappl_t_datainfo
*
)
calloc
(
applctx
->
total_cellsize
,
sizeof
(
nmpsappl_t_datainfo
));
nmps_create_lock
(
&
sts
);
if
(
EVEN
(
sts
))
return
sts
;
applctx
->
options
=
options
;
return
NMPS__SUCCESS
;
...
...
@@ -509,8 +514,10 @@ nmpsappl_Mirror(
for
(
i
=
0
;
i
<
applctx
->
cellist_count
;
i
++
)
{
cellist_ptr
=
applctx
->
cellist
[
i
];
nmps_Lock
;
memcpy
(
cellist_ptr
->
tmp_cell
,
cellist_ptr
->
object_ptr
,
cellist_ptr
->
tmp_size
);
nmps_Unlock
;
}
applctx
->
data_count
=
0
;
...
...
nmps/lib/nmps/src/nmps_plc.c
View file @
0dfc7602
/*
* Proview $Id: nmps_plc.c,v 1.
2 2006-01-26 08:15:11
claes Exp $
* Proview $Id: nmps_plc.c,v 1.
3 2008-01-25 14:35:29
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -34,6 +34,7 @@
#include "pwr_nmpsclasses.h"
#include "rt_gdh.h"
#include "rt_plc.h"
#include "rt_nmps_lock.h"
#include "nmps.h"
#define ODD(a) (((int)(a) & 1) != 0)
...
...
@@ -59,8 +60,7 @@
/* NMpsCell
*/
void
NMpsCell_init_time
(
object
)
pwr_sClass_NMpsCell
*
object
;
void
NMpsCell_init_time
(
pwr_sClass_NMpsCell
*
object
)
{
pwr_sAttrRef
attrref
;
plc_t_DataInfo
*
data_index
;
...
...
@@ -89,11 +89,13 @@ pwr_sClass_NMpsCell *object;
object
->
ReloadDone
|=
NMPS_CELL_INITIALIZED
;
}
void
NMpsCell_init
(
object
)
pwr_sClass_NMpsCell
*
object
;
void
NMpsCell_init
(
pwr_sClass_NMpsCell
*
object
)
{
plc_t_DataInfo
*
data_index
;
int
i
;
pwr_tStatus
sts
;
nmps_create_lock
(
&
sts
);
if
(
!
(
object
->
Function
&
NMPS_CELLFUNC_BACKUP
))
NMpsCell_init_time
(
object
);
...
...
@@ -137,16 +139,18 @@ void NMpsCell_exec(
plc_t_DataInfo
cpy_buf
[
NMPS_CELL_SIZE
];
#endif
if
(
object
->
InitTime
)
{
if
(
object
->
InitTime
)
{
if
(
!
(
object
->
ReloadDone
&
NMPS_CELL_RELOADDONE
))
return
;
else
{
else
{
nmps_Lock
;
NMpsCell_init_time
(
object
);
object
->
ReloadDone
&=
~
NMPS_CELL_RELOADDONE
;
}
}
else
nmps_Lock
;
if
(
object
->
FrontNew
)
object
->
FrontNew
=
0
;
if
(
object
->
RearNew
)
object
->
RearNew
=
0
;
...
...
@@ -417,8 +421,10 @@ void NMpsCell_exec(
{
case
NMPS_OPTYPE_FORWARD_FRONT
:
/* Insert at front of object front of data */
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
if
(
object
->
LastIndex
>
0
)
{
#if defined OS_LINUX
...
...
@@ -452,6 +458,7 @@ void NMpsCell_exec(
{
/* This it not the correct object */
object
->
InFlag
=
0
;
nmps_Unlock
;
return
;
}
object
->
Data1_Back
=
1
;
...
...
@@ -463,8 +470,10 @@ void NMpsCell_exec(
object
->
InFlag
=
0
;
break
;
case
NMPS_OPTYPE_FORWARD_UNIT
:
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
if
(
object
->
LastIndex
>
0
)
{
#if defined OS_LINUX
...
...
@@ -494,8 +503,10 @@ void NMpsCell_exec(
break
;
case
NMPS_OPTYPE_REVERSE_BACK
:
/* Insert at rear of object back of data */
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
data_last
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
data_last
+=
object
->
LastIndex
;
data_last
->
DataP
=
object
->
InPointer
;
...
...
@@ -513,8 +524,10 @@ void NMpsCell_exec(
break
;
case
NMPS_OPTYPE_REVERSE_UNIT
:
/* Insert at rear of object all of data */
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
data_last
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
data_last
+=
object
->
LastIndex
;
data_last
->
DataP
=
object
->
InPointer
;
...
...
@@ -538,6 +551,7 @@ void NMpsCell_exec(
{
/* This it not the correct object */
object
->
InFlag
=
0
;
nmps_Unlock
;
return
;
}
data_last
->
Data_Front
=
1
;
...
...
@@ -561,6 +575,7 @@ void NMpsCell_exec(
if
(
object
->
LastIndex
==
0
)
{
object
->
OutRearFlag
=
0
;
nmps_Unlock
;
return
;
}
...
...
@@ -606,6 +621,7 @@ void NMpsCell_exec(
if
(
object
->
LastIndex
==
0
)
{
object
->
OutFrontFlag
=
0
;
nmps_Unlock
;
return
;
}
#if defined OS_LINUX
...
...
@@ -648,15 +664,20 @@ void NMpsCell_exec(
if
(
object
->
Function
&
NMPS_CELLFUNC_BACKUP
)
object
->
BackupNow
=
1
;
}
object
->
NumberOfData
=
object
->
LastIndex
;
nmps_Unlock
;
}
/* NMpsStoreCell
*/
void
NMpsStoreCell_init
(
object
)
pwr_sClass_NMpsStoreCell
*
object
;
void
NMpsStoreCell_init
(
pwr_sClass_NMpsStoreCell
*
object
)
{
plc_t_DataInfo
*
data_index
;
int
i
;
pwr_tStatus
sts
;
nmps_create_lock
(
&
sts
);
if
(
!
(
object
->
Function
&
NMPS_CELLFUNC_BACKUP
))
NMpsCell_init_time
(
(
pwr_sClass_NMpsCell
*
)
object
);
...
...
@@ -707,10 +728,13 @@ void NMpsStoreCell_exec(
return
;
else
{
NMpsCell_init_time
(
object
);
nmps_Lock
;
NMpsCell_init_time
(
(
pwr_sClass_NMpsCell
*
)
object
);
object
->
ReloadDone
&=
~
NMPS_CELL_RELOADDONE
;
}
}
else
nmps_Lock
;
if
(
object
->
FrontNew
)
object
->
FrontNew
=
0
;
if
(
object
->
RearNew
)
object
->
RearNew
=
0
;
...
...
@@ -1144,8 +1168,10 @@ void NMpsStoreCell_exec(
{
case
NMPS_OPTYPE_FORWARD_FRONT
:
/* Insert at front of object front of data */
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
if
(
object
->
LastIndex
>
0
)
{
#if defined OS_LINUX
...
...
@@ -1178,6 +1204,7 @@ void NMpsStoreCell_exec(
{
/* This it not the correct object */
object
->
InFlag
=
0
;
nmps_Unlock
;
return
;
}
object
->
Data1_Back
=
1
;
...
...
@@ -1189,8 +1216,10 @@ void NMpsStoreCell_exec(
object
->
InFlag
=
0
;
break
;
case
NMPS_OPTYPE_FORWARD_UNIT
:
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
if
(
object
->
LastIndex
>
0
)
{
#if defined OS_LINUX
...
...
@@ -1219,8 +1248,10 @@ void NMpsStoreCell_exec(
break
;
case
NMPS_OPTYPE_REVERSE_BACK
:
/* Insert at rear of object back of data */
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
data_last
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
data_last
+=
object
->
LastIndex
;
data_last
->
DataP
=
object
->
InPointer
;
...
...
@@ -1235,8 +1266,10 @@ void NMpsStoreCell_exec(
break
;
case
NMPS_OPTYPE_REVERSE_UNIT
:
/* Insert at rear of object all of data */
if
(
object
->
CellFull
)
return
;
if
(
object
->
CellFull
)
{
nmps_Unlock
;
return
;
}
data_last
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
data_last
+=
object
->
LastIndex
;
data_last
->
DataP
=
object
->
InPointer
;
...
...
@@ -1257,6 +1290,7 @@ void NMpsStoreCell_exec(
{
/* This it not the correct object */
object
->
InFlag
=
0
;
nmps_Unlock
;
return
;
}
data_last
->
Data_Front
=
1
;
...
...
@@ -1277,6 +1311,7 @@ void NMpsStoreCell_exec(
if
(
object
->
LastIndex
==
0
)
{
object
->
OutRearFlag
=
0
;
nmps_Unlock
;
return
;
}
...
...
@@ -1344,6 +1379,7 @@ void NMpsStoreCell_exec(
if
(
object
->
LastIndex
==
0
)
{
object
->
OutFrontFlag
=
0
;
nmps_Unlock
;
return
;
}
...
...
@@ -1410,6 +1446,8 @@ void NMpsStoreCell_exec(
if
(
object
->
Function
&
NMPS_CELLFUNC_BACKUP
)
object
->
BackupNow
=
1
;
}
object
->
NumberOfData
=
object
->
DataSelected
;
nmps_Unlock
;
}
/*_*
...
...
src/lib/rt/src/rt_nmps_lock.c
0 → 100644
View file @
0dfc7602
/*
* Proview $Id: rt_nmps_lock.c,v 1.1 2008-01-25 14:32:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "pwr.h"
#include "rt_sect.h"
#include "rt_nmps_lock.h"
sect_sHead
*
nmps_locksect
=
0
;
void
nmps_create_lock
(
pwr_tStatus
*
sts
)
{
pwr_tBoolean
created
;
if
(
!
nmps_locksect
)
{
nmps_locksect
=
sect_Alloc
(
sts
,
&
created
,
0
,
sizeof
(
sect_sMutex
),
nmps_cName_Lock
);
if
(
ODD
(
*
sts
)
&&
created
)
sect_InitLock
(
sts
,
nmps_locksect
,
(
sect_sMutex
*
)
nmps_locksect
->
base
);
}
}
void
nmps_unlink_lock
(
pwr_tStatus
*
sts
)
{
if
(
nmps_locksect
)
{
if
(
shmdt
(
nmps_locksect
)
==
-
1
)
*
sts
=
0
;
else
*
sts
=
1
;
}
}
void
nmps_delete_lock
(
pwr_tStatus
*
sts
)
{
if
(
nmps_locksect
)
{
char
segname
[
128
];
char
busid
[
8
];
char
*
str
=
getenv
(
pwr_dEnvBusId
);
key_t
key
;
int
shm_id
;
struct
shmid_ds
ds
;
strncpy
(
busid
,
(
str
?
str
:
"XXX"
),
3
);
busid
[
3
]
=
'\0'
;
sprintf
(
segname
,
"%s_%.3s"
,
nmps_cName_Lock
,
busid
);
key
=
ftok
(
segname
,
'P'
);
shm_id
=
shmget
(
key
,
0
,
0660
);
if
(
shmdt
(
nmps_locksect
->
base
)
==
-
1
)
printf
(
"Detach of nmps lock failed
\n
"
);
if
(
shmctl
(
shm_id
,
IPC_RMID
,
&
ds
)
==
-
1
)
printf
(
"Remove of nmps lock failed
\n
"
);
unlink
(
segname
);
sect_Free
(
sts
,
nmps_locksect
);
}
}
src/lib/rt/src/rt_nmps_lock.h
0 → 100644
View file @
0dfc7602
/*
* Proview $Id: rt_nmps_lock.h,v 1.1 2008-01-25 14:32:44 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef rt_nmps_lock_h
#define rt_nmps_lock_h
#include "pwr.h"
#include "rt_sect.h"
#define nmps_cName_Lock "/tmp/pwr_nmps_lock"
#define nmps_Lock sect_Lock( NULL, nmps_locksect, (sect_sMutex *)nmps_locksect->base);
#define nmps_Unlock sect_Unlock( NULL, nmps_locksect, (sect_sMutex *)nmps_locksect->base);
extern
sect_sHead
*
nmps_locksect
;
void
nmps_create_lock
(
pwr_tStatus
*
sts
);
void
nmps_delete_lock
(
pwr_tStatus
*
sts
);
void
nmps_unlink_lock
(
pwr_tStatus
*
sts
);
#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