Commit 59c8fac4 authored by yoogx's avatar yoogx

* Separate concurrency constructs from GQueue processing logic

        For openaadl/ocarina#159
parent 74d5d911
......@@ -3,24 +3,16 @@ include $(top_srcdir)/Makefile.common
AUTOMAKE_OPTIONS = no-dependencies
SUBDIRS=drivers monitoring simulator
EXTRA_DIST = $(srcdir)/po_hi_common.h \
$(srcdir)/po_hi_debug.h \
$(srcdir)/po_hi_marshallers.h \
$(srcdir)/po_hi_messages.h \
$(srcdir)/po_hi_protected.h \
$(srcdir)/po_hi_returns.h \
$(srcdir)/po_hi_gqueue.h \
$(srcdir)/po_hi_monitor.h \
$(srcdir)/po_hi_lua.h \
$(srcdir)/po_hi_storage.h \
$(srcdir)/po_hi_giop.h \
$(srcdir)/po_hi_utils.h \
$(srcdir)/po_hi_task.h \
$(srcdir)/po_hi_time.h \
$(srcdir)/po_hi_types.h \
$(srcdir)/po_hi_main.h \
$(srcdir)/po_hi_simulink.h \
$(srcdir)/po_hi_transport.h
EXTRA_DIST = $(srcdir)/po_hi_common.h $(srcdir)/po_hi_debug.h \
$(srcdir)/po_hi_marshallers.h $(srcdir)/po_hi_messages.h \
$(srcdir)/po_hi_protected.h $(srcdir)/po_hi_returns.h \
$(srcdir)/po_hi_gqueue.h $(srcdir)/po_hi_monitor.h \
$(srcdir)/po_hi_lua.h $(srcdir)/po_hi_storage.h \
$(srcdir)/po_hi_giop.h $(srcdir)/po_hi_utils.h \
$(srcdir)/po_hi_task.h $(srcdir)/po_hi_time.h \
$(srcdir)/po_hi_types.h $(srcdir)/po_hi_main.h \
$(srcdir)/po_hi_simulink.h $(srcdir)/po_hi_transport.h \
$(srcdir)/po_hi_semaphore.h
CLEANFILES = *~
......
......@@ -5,12 +5,13 @@
*
* For more informations, please visit http://taste.tuxfamily.org/wiki
*
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2014 ESA & ISAE.
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2018 ESA & ISAE.
*/
#ifndef __PO_HI_PROTECTED_H__
#define __PO_HI_PROTECTED_H__
#include <stdint.h>
#include <deployment.h>
......
......@@ -5,7 +5,7 @@
*
* For more informations, please visit http://taste.tuxfamily.org/wiki
*
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2014 ESA & ISAE.
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2018 ESA & ISAE.
*/
#ifndef __PO_HI_RETURNS_H__
......@@ -38,6 +38,7 @@
#define __PO_HI_ERROR_TRANSPORT_SEND -55
#define __PO_HI_ERROR_PTHREAD_BARRIER -56
/* Errors related to the protected and semaphore API */
#define __PO_HI_ERROR_PROTECTED_LOCK -60
#define __PO_HI_ERROR_PROTECTED_UNLOCK -61
#define __PO_HI_ERROR_PROTECTED_CREATE -62
......@@ -46,6 +47,10 @@
#define __PO_HI_ERROR_MUTEX_UNLOCK -61
#define __PO_HI_ERROR_MUTEX_CREATE -62
#define __PO_HI_ERROR_SEM_WAIT -60
#define __PO_HI_ERROR_SEM_RELEASE -61
#define __PO_HI_ERROR_SEM_CREATE -62
/* GIOP error code */
#define __PO_HI_GIOP_INVALID_SIZE -100
#define __PO_HI_GIOP_INVALID_VERSION -120
......
/*
* This is a part of PolyORB-HI-C distribution, a minimal
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* For more informations, please visit http://taste.tuxfamily.org/wiki
*
* Copyright (C) 2018 ESA & ISAE.
*/
#ifndef __PO_HI_SEMAPHORE_H__
#define __PO_HI_SEMAPHORE_H__
#include <po_hi_protected.h>
#include <stdint.h>
#include <deployment.h>
#include <po_hi_gqueue.h>
//#define __PO_HI_PROTECTED_TYPE_REGULAR 0
//#define __PO_HI_PROTECTED_TYPE_PIP 1
//#define __PO_HI_PROTECTED_TYPE_PCP 2
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#elif defined (__PO_HI_RTEMS_CLASSIC_API)
#include <rtems.h>
#elif defined (XENO_NATIVE)
#include <native/mutex.h>
#elif defined (_WIN32)
#include <windows.h>
#endif
typedef struct
{
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
//protocol and priority to add
__po_hi_mutex_t mutex;
pthread_cond_t posix_condvar;
pthread_condattr_t posix_condattr;
#elif defined (__PO_HI_RTEMS_CLASSIC_API)
rtems_id rtems_sem;
rtems_id rtems_barrier;
#elif defined (XENO_NATIVE)
__po_hi_mutex_t mutex;
RT_COND xeno_condvar;
#elif defined (_WIN32)
HANDLE win32_event;
CRITICAL_SECTION win32_criticalsection;
#endif
}__po_hi_sem_t;
/** Basics functions on semaphores */
int __po_hi_sem_init(__po_hi_sem_t* sem, const __po_hi_mutex_protocol_t protocol, const int priority, int nb);
int __po_hi_sem_wait(__po_hi_sem_t* sem);
int __po_hi_sem_mutex_wait(__po_hi_sem_t* sem);
int __po_hi_sem_release(__po_hi_sem_t* sem);
int __po_hi_sem_mutex_release(__po_hi_sem_t* sem);
/** Functions used to fill the __po_hi_gqueues_semaphores array */
int __po_hi_sem_init_gqueue(__po_hi_sem_t array[__PO_HI_NB_TASKS], __po_hi_task_id id);
int __po_hi_sem_wait_gqueue(__po_hi_sem_t array[__PO_HI_NB_TASKS], __po_hi_task_id id);
int __po_hi_sem_mutex_wait_gqueue(__po_hi_sem_t array[__PO_HI_NB_TASKS], __po_hi_task_id id);
int __po_hi_sem_release_gqueue(__po_hi_sem_t array[__PO_HI_NB_TASKS], __po_hi_task_id id);
int __po_hi_sem_mutex_release_gqueue(__po_hi_sem_t array[__PO_HI_NB_TASKS], __po_hi_task_id id);
#endif /* __PO_HI_SEMAPHORE_H__ */
......@@ -92,23 +92,17 @@ ifeq ($(NEED_TRANSPORT), yes)
PO_HI_OBJS = po_hi_task.o po_hi_time.o po_hi_protected.o \
po_hi_main.o po_hi_messages.o po_hi_marshallers.o \
po_hi_giop.o po_hi_utils.o po_hi_types.o po_hi_monitor.o \
po_hi_storage.o po_hi_gqueue.o po_hi_driver_exarm.o \
po_hi_driver_keyboard.o \
po_hi_driver_exarm_ni_6071e_analog.o \
po_hi_driver_exarm_ni_6071e_digital.o \
po_hi_driver_usbbrick_spacewire.o \
po_hi_driver_linux_serial.o \
po_hi_driver_leon_serial.o \
po_hi_driver_leon_eth.o \
po_hi_driver_serial_common.o \
po_hi_driver_sockets.o \
po_hi_driver_rtems_ne2000.o \
po_hi_driver_rasta_serial.o \
po_hi_driver_rasta_common.o \
po_hi_driver_rasta_1553.o \
po_hi_driver_xc4v_fpga.o \
po_hi_driver_rasta_1553_brmlib.o \
po_hi_driver_rasta_spacewire.o $(ACTUAL_TRANSPORT) \
po_hi_semaphore.o po_hi_storage.o po_hi_gqueue.o \
po_hi_driver_exarm.o po_hi_driver_keyboard.o \
po_hi_driver_exarm_ni_6071e_analog.o \
po_hi_driver_exarm_ni_6071e_digital.o \
po_hi_driver_usbbrick_spacewire.o po_hi_driver_linux_serial.o \
po_hi_driver_leon_serial.o po_hi_driver_leon_eth.o \
po_hi_driver_serial_common.o po_hi_driver_sockets.o \
po_hi_driver_rtems_ne2000.o po_hi_driver_rasta_serial.o \
po_hi_driver_rasta_common.o po_hi_driver_rasta_1553.o \
po_hi_driver_xc4v_fpga.o po_hi_driver_rasta_1553_brmlib.o \
po_hi_driver_rasta_spacewire.o $(ACTUAL_TRANSPORT) \
po_hi_transport.o $(TARGET_TRANSPORT_SOURCES)
GENERATED_OBJS = activity.o subprograms.o types.o request.o \
......
......@@ -9,7 +9,7 @@ C_FILES = $(srcdir)/po_hi_task.c $(srcdir)/po_hi_main.c \
$(srcdir)/po_hi_storage.c $(srcdir)/po_hi_types.c \
$(srcdir)/po_hi_utils.c $(srcdir)/po_hi_simulink.c \
$(srcdir)/po_hi_gprof_rtems_leon.c \
$(srcdir)/po_hi_time.c
$(srcdir)/po_hi_time.c $(srcdir)/po_hi_semaphore.c
csrc = ${shell $(CYGPATH_U) '$(OCARINA_RUNTIME)/polyorb-hi-c/src'}
......
This diff is collapsed.
......@@ -5,7 +5,7 @@
*
* For more informations, please visit http://taste.tuxfamily.org/wiki
*
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2017 ESA & ISAE.
* Copyright (C) 2007-2009 Telecom ParisTech, 2010-2018 ESA & ISAE.
*/
#include <po_hi_config.h>
......@@ -94,6 +94,7 @@ int __po_hi_protected_unlock (__po_hi_protected_t protected_id)
int __po_hi_mutex_init (__po_hi_mutex_t* mutex, const __po_hi_mutex_protocol_t protocol, const int priority)
{
#ifdef __PO_HI_RTEMS_CLASSIC_API
//illogic
static int nb_mutex = 0;
#endif
......
This diff is collapsed.
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