summaryrefslogtreecommitdiff
path: root/src/lib/shm_rbuff.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2017-12-02 14:01:03 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-12-02 14:56:20 +0100
commit9b8a3e11c558877c09416991ff1ec840fea6d0ab (patch)
treef2faf7a4ab45687782a010fb6e48829e8ee1bdeb /src/lib/shm_rbuff.c
parentf43e5e2329fb798047d15dd0748e5eef3359c966 (diff)
downloadouroboros-9b8a3e11c558877c09416991ff1ec840fea6d0ab.tar.gz
ouroboros-9b8a3e11c558877c09416991ff1ec840fea6d0ab.zip
lib, tools: Rename application process and instance
This refactors ouroboros to use "program" instead of "application process" and "process" instead of "application process instance" to align with current naming in current Operating Systems courses instead of the ISO nomenclature adopted by RINA. This change permeates through the entire implementation. Also contains some minor other refactors. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/lib/shm_rbuff.c')
-rw-r--r--src/lib/shm_rbuff.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c
index 00f0b92b..db957168 100644
--- a/src/lib/shm_rbuff.c
+++ b/src/lib/shm_rbuff.c
@@ -45,7 +45,7 @@
#define FN_MAX_CHARS 255
-#define SHM_RB_FILE_SIZE ((SHM_BUFFER_SIZE) * sizeof(ssize_t) \
+#define SHM_RB_FILE_SIZE ((SHM_BUFFER_SIZE) * sizeof(ssize_t) \
+ 3 * sizeof(size_t) \
+ sizeof(pthread_mutex_t) \
+ 2 * sizeof (pthread_cond_t))
@@ -65,7 +65,7 @@ struct shm_rbuff {
pthread_mutex_t * lock; /* lock all free space in shm */
pthread_cond_t * add; /* SDU arrived */
pthread_cond_t * del; /* SDU removed */
- pid_t api; /* api of the owner */
+ pid_t pid; /* pid of the owner */
int port_id; /* port_id of the flow */
};
@@ -80,14 +80,16 @@ void shm_rbuff_close(struct shm_rbuff * rb)
#define MM_FLAGS (PROT_READ | PROT_WRITE)
-struct shm_rbuff * rbuff_create(pid_t api, int port_id, int flags)
+struct shm_rbuff * rbuff_create(pid_t pid,
+ int port_id,
+ int flags)
{
struct shm_rbuff * rb;
int fd;
ssize_t * shm_base;
char fn[FN_MAX_CHARS];
- sprintf(fn, SHM_RBUFF_PREFIX "%d.%d", api, port_id);
+ sprintf(fn, SHM_RBUFF_PREFIX "%d.%d", pid, port_id);
rb = malloc(sizeof(*rb));
if (rb == NULL)
@@ -113,9 +115,8 @@ struct shm_rbuff * rbuff_create(pid_t api, int port_id, int flags)
rb->lock = (pthread_mutex_t *) (rb->acl + 1);
rb->add = (pthread_cond_t *) (rb->lock + 1);
rb->del = rb->add + 1;
-
- rb->api = api;
- rb->port_id = port_id;
+ rb->pid = pid;
+ rb->port_id = port_id;
return rb;
@@ -129,7 +130,8 @@ struct shm_rbuff * rbuff_create(pid_t api, int port_id, int flags)
return NULL;
}
-struct shm_rbuff * shm_rbuff_create(pid_t api, int port_id)
+struct shm_rbuff * shm_rbuff_create(pid_t pid,
+ int port_id)
{
struct shm_rbuff * rb;
pthread_mutexattr_t mattr;
@@ -138,7 +140,7 @@ struct shm_rbuff * shm_rbuff_create(pid_t api, int port_id)
mask = umask(0);
- rb = rbuff_create(api, port_id, O_CREAT | O_EXCL | O_RDWR);
+ rb = rbuff_create(pid, port_id, O_CREAT | O_EXCL | O_RDWR);
umask(mask);
@@ -172,7 +174,7 @@ struct shm_rbuff * shm_rbuff_create(pid_t api, int port_id)
*rb->head = 0;
*rb->tail = 0;
- rb->api = api;
+ rb->pid = pid;
rb->port_id = port_id;
pthread_mutexattr_destroy(&mattr);
@@ -194,9 +196,10 @@ struct shm_rbuff * shm_rbuff_create(pid_t api, int port_id)
return NULL;
}
-struct shm_rbuff * shm_rbuff_open(pid_t api, int port_id)
+struct shm_rbuff * shm_rbuff_open(pid_t pid,
+ int port_id)
{
- return rbuff_create(api, port_id, O_RDWR);
+ return rbuff_create(pid, port_id, O_RDWR);
}
#if (defined(SHM_RBUFF_LOCKLESS) && \