summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-14 15:21:14 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-15 10:55:38 +0200
commitac741625b0926a0329627beca52174edd69e587b (patch)
treef8f186efe3118359ae32a4a2eeedbe79e38c340e /cpukit
parentlibio: Add hold/drop iop reference (diff)
downloadrtems-ac741625b0926a0329627beca52174edd69e587b.tar.bz2
libio: Use FIFO for iop free list
Update #3136.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/libcsupport/include/rtems/libio_.h3
-rw-r--r--cpukit/libcsupport/src/libio.c23
-rw-r--r--cpukit/libcsupport/src/libio_init.c10
-rw-r--r--cpukit/libcsupport/src/resource_snapshot.c2
4 files changed, 25 insertions, 13 deletions
diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h
index dc1fe9808a..cf4ea78f7e 100644
--- a/cpukit/libcsupport/include/rtems/libio_.h
+++ b/cpukit/libcsupport/include/rtems/libio_.h
@@ -66,7 +66,8 @@ extern rtems_id rtems_libio_semaphore;
extern const uint32_t rtems_libio_number_iops;
extern rtems_libio_t rtems_libio_iops[];
-extern rtems_libio_t *rtems_libio_iop_freelist;
+extern void *rtems_libio_iop_free_head;
+extern void **rtems_libio_iop_free_tail;
extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers;
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 26fa7b2f67..0abb082a66 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -108,14 +108,21 @@ int rtems_libio_to_fcntl_flags( unsigned int flags )
rtems_libio_t *rtems_libio_allocate( void )
{
- rtems_libio_t *iop = NULL;
+ rtems_libio_t *iop;
rtems_libio_lock();
- if (rtems_libio_iop_freelist) {
- iop = rtems_libio_iop_freelist;
- rtems_libio_iop_freelist = iop->data1;
- memset( iop, 0, sizeof(*iop) );
+ iop = rtems_libio_iop_free_head;
+
+ if ( iop != NULL ) {
+ void *next;
+
+ next = iop->data1;
+ rtems_libio_iop_free_head = next;
+
+ if ( next == NULL ) {
+ rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
+ }
}
rtems_libio_unlock();
@@ -131,9 +138,9 @@ void rtems_libio_free(
rtems_libio_lock();
- iop->flags = 0;
- iop->data1 = rtems_libio_iop_freelist;
- rtems_libio_iop_freelist = iop;
+ iop = memset( iop, 0, sizeof( *iop ) );
+ *rtems_libio_iop_free_tail = iop;
+ rtems_libio_iop_free_tail = &iop->data1;
rtems_libio_unlock();
}
diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c
index 3fa9e0995f..9c24b146ea 100644
--- a/cpukit/libcsupport/src/libio_init.c
+++ b/cpukit/libcsupport/src/libio_init.c
@@ -38,8 +38,11 @@
* File descriptor Table Information
*/
-rtems_id rtems_libio_semaphore;
-rtems_libio_t *rtems_libio_iop_freelist;
+rtems_id rtems_libio_semaphore;
+
+void *rtems_libio_iop_free_head;
+
+void **rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
static void rtems_libio_init( void )
{
@@ -50,10 +53,11 @@ static void rtems_libio_init( void )
if (rtems_libio_number_iops > 0)
{
- iop = rtems_libio_iop_freelist = &rtems_libio_iops[0];
+ iop = rtems_libio_iop_free_head = &rtems_libio_iops[0];
for (i = 0 ; (i + 1) < rtems_libio_number_iops ; i++, iop++)
iop->data1 = iop + 1;
iop->data1 = NULL;
+ rtems_libio_iop_free_tail = &iop->data1;
}
/*
diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c
index d0dda9f7ca..9e026ff222 100644
--- a/cpukit/libcsupport/src/resource_snapshot.c
+++ b/cpukit/libcsupport/src/resource_snapshot.c
@@ -87,7 +87,7 @@ static int open_files(void)
rtems_libio_lock();
- iop = rtems_libio_iop_freelist;
+ iop = rtems_libio_iop_free_head;
while (iop != NULL) {
++free_count;