summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-04-26 14:28:52 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-04 10:53:51 +0200
commit5a4bb758c0017374352ccf065fb1aac4ebb3e27d (patch)
tree5b69f58aac905d40a70923eaab5b0fa43cfa57bb
parentRemove CVS-Ids. (diff)
downloadrtems-5a4bb758c0017374352ccf065fb1aac4ebb3e27d.tar.bz2
Filesystem: Remove per file descriptor semaphore
The per file descriptor semaphore (field of rtems_libio_t) is unused in RTEMS. There is a considerable memory overhead due to that. A semaphore needs roughly 124 bytes which is huge compared to the approximately 72 bytes for the file descriptor structure itself. Device drivers can create their own synchronization primitives in the open handler on demand.
-rw-r--r--cpukit/libcsupport/include/rtems/libio.h1
-rw-r--r--cpukit/libcsupport/src/libio.c28
-rw-r--r--cpukit/sapi/include/confdefs.h6
-rw-r--r--testsuites/sptests/spfatal14/Makefile.am1
-rw-r--r--testsuites/sptests/spfatal14/testcase.h3
-rw-r--r--testsuites/sptests/spfatal15/Makefile.am1
-rw-r--r--testsuites/sptests/spfatal15/testcase.h3
-rw-r--r--testsuites/sptests/spfatal16/testcase.h4
-rw-r--r--testsuites/sptests/spfatal17/Makefile.am2
-rw-r--r--testsuites/sptests/spfatal18/Makefile.am2
-rw-r--r--testsuites/sptests/spfatal19/Makefile.am2
-rw-r--r--testsuites/sptests/spfatal20/testcase.h4
-rw-r--r--testsuites/sptests/spfifo02/init.c4
13 files changed, 14 insertions, 47 deletions
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index f1908f7da2..04ca52c4aa 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1165,7 +1165,6 @@ struct rtems_libio_tt {
off_t offset; /* current offset into file */
uint32_t flags;
rtems_filesystem_location_info_t pathinfo;
- rtems_id sem;
uint32_t data0; /* private to "driver" */
void *data1; /* ... */
};
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 985ad8bad9..e75b66bfaf 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -131,36 +131,19 @@ int rtems_libio_to_fcntl_flags( uint32_t flags )
rtems_libio_t *rtems_libio_allocate( void )
{
- rtems_libio_t *iop, *next;
- rtems_status_code rc;
- rtems_id sema;
+ rtems_libio_t *iop = NULL;
rtems_libio_lock();
if (rtems_libio_iop_freelist) {
- rc = rtems_semaphore_create(
- RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops),
- 1,
- RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
- 0,
- &sema
- );
- if (rc != RTEMS_SUCCESSFUL)
- goto failed;
iop = rtems_libio_iop_freelist;
- next = iop->data1;
- (void) memset( iop, 0, sizeof(rtems_libio_t) );
+ rtems_libio_iop_freelist = iop->data1;
+ memset( iop, 0, sizeof(*iop) );
iop->flags = LIBIO_FLAGS_OPEN;
- iop->sem = sema;
- rtems_libio_iop_freelist = next;
- goto done;
}
-failed:
- iop = 0;
-
-done:
rtems_libio_unlock();
+
return iop;
}
@@ -179,9 +162,6 @@ void rtems_libio_free(
rtems_libio_lock();
- if (iop->sem)
- rtems_semaphore_delete(iop->sem);
-
iop->flags &= ~LIBIO_FLAGS_OPEN;
iop->data1 = rtems_libio_iop_freelist;
rtems_libio_iop_freelist = iop;
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index d896c59e82..3e4cb90940 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -119,11 +119,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
#endif
/**
- * From the number of file descriptors, we can determine how many
- * semaphores the implementation will require.
+ * Semaphore count used by the IO library.
*/
-#define CONFIGURE_LIBIO_SEMAPHORES \
- (CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS + 1)
+#define CONFIGURE_LIBIO_SEMAPHORES 1
#ifdef CONFIGURE_INIT
/**
diff --git a/testsuites/sptests/spfatal14/Makefile.am b/testsuites/sptests/spfatal14/Makefile.am
index c070b3c4dd..e5d1ee1754 100644
--- a/testsuites/sptests/spfatal14/Makefile.am
+++ b/testsuites/sptests/spfatal14/Makefile.am
@@ -11,7 +11,6 @@ include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
-AM_CPPFLAGS += -DSEMAPHORES_REMAINING=5
LINK_OBJS = $(spfatal14_OBJECTS)
LINK_LIBS = $(spfatal14_LDLIBS)
diff --git a/testsuites/sptests/spfatal14/testcase.h b/testsuites/sptests/spfatal14/testcase.h
index e9e95b62e0..a63541b9e4 100644
--- a/testsuites/sptests/spfatal14/testcase.h
+++ b/testsuites/sptests/spfatal14/testcase.h
@@ -17,8 +17,7 @@
#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
#define FATAL_ERROR_EXPECTED_ERROR 0x55544431
-#define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
- CONSUME_SEMAPHORE_DRIVERS
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 1
void force_error()
{
diff --git a/testsuites/sptests/spfatal15/Makefile.am b/testsuites/sptests/spfatal15/Makefile.am
index ffeb24a418..485c92af6b 100644
--- a/testsuites/sptests/spfatal15/Makefile.am
+++ b/testsuites/sptests/spfatal15/Makefile.am
@@ -11,7 +11,6 @@ include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
-AM_CPPFLAGS += -DSEMAPHORES_REMAINING=6
LINK_OBJS = $(spfatal15_OBJECTS)
LINK_LIBS = $(spfatal15_LDLIBS)
diff --git a/testsuites/sptests/spfatal15/testcase.h b/testsuites/sptests/spfatal15/testcase.h
index 66ca243917..7570e4e5c8 100644
--- a/testsuites/sptests/spfatal15/testcase.h
+++ b/testsuites/sptests/spfatal15/testcase.h
@@ -16,8 +16,7 @@
#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE
#define FATAL_ERROR_EXPECTED_ERROR 0x55544432
-#define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
- { consume_semaphores_initialize, NULL, NULL, NULL, NULL, NULL }
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 2
void force_error()
{
diff --git a/testsuites/sptests/spfatal16/testcase.h b/testsuites/sptests/spfatal16/testcase.h
index 6a228381a6..fed0d4a7ff 100644
--- a/testsuites/sptests/spfatal16/testcase.h
+++ b/testsuites/sptests/spfatal16/testcase.h
@@ -24,5 +24,7 @@
void force_error()
{
- /* we will not run this far */
+ /* This fatal error depends on the Termios device configuration */
+ printk( "*** END OF TEST FATAL " FATAL_ERROR_TEST_NAME " ***\n" );
+ rtems_test_exit(0);
}
diff --git a/testsuites/sptests/spfatal17/Makefile.am b/testsuites/sptests/spfatal17/Makefile.am
index 8e2557279c..745ca43f3e 100644
--- a/testsuites/sptests/spfatal17/Makefile.am
+++ b/testsuites/sptests/spfatal17/Makefile.am
@@ -11,7 +11,7 @@ include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
-AM_CPPFLAGS += -DSEMAPHORES_REMAINING=4
+AM_CPPFLAGS += -DSEMAPHORES_REMAINING=3
LINK_OBJS = $(spfatal17_OBJECTS)
LINK_LIBS = $(spfatal17_LDLIBS)
diff --git a/testsuites/sptests/spfatal18/Makefile.am b/testsuites/sptests/spfatal18/Makefile.am
index a43608c5ca..31597bbf51 100644
--- a/testsuites/sptests/spfatal18/Makefile.am
+++ b/testsuites/sptests/spfatal18/Makefile.am
@@ -11,7 +11,7 @@ include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
-AM_CPPFLAGS += -DSEMAPHORES_REMAINING=3
+AM_CPPFLAGS += -DSEMAPHORES_REMAINING=2
LINK_OBJS = $(spfatal18_OBJECTS)
LINK_LIBS = $(spfatal18_LDLIBS)
diff --git a/testsuites/sptests/spfatal19/Makefile.am b/testsuites/sptests/spfatal19/Makefile.am
index 8f4105c0e7..8471aae478 100644
--- a/testsuites/sptests/spfatal19/Makefile.am
+++ b/testsuites/sptests/spfatal19/Makefile.am
@@ -11,7 +11,7 @@ include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
-AM_CPPFLAGS += -DSEMAPHORES_REMAINING=2
+AM_CPPFLAGS += -DSEMAPHORES_REMAINING=1
LINK_OBJS = $(spfatal19_OBJECTS)
LINK_LIBS = $(spfatal19_LDLIBS)
diff --git a/testsuites/sptests/spfatal20/testcase.h b/testsuites/sptests/spfatal20/testcase.h
index 566c4bfc36..08721a0f8d 100644
--- a/testsuites/sptests/spfatal20/testcase.h
+++ b/testsuites/sptests/spfatal20/testcase.h
@@ -9,10 +9,6 @@
* $Id$
*/
-/* generate fatal errors in termios.c
- * rtems_semaphore_create( rtems_build_name ('T', 'R', 'r', c),...);
- */
-
#define FATAL_ERROR_TEST_NAME "20"
#define FATAL_ERROR_DESCRIPTION \
"rtems_termios_initialize cannot create semaphore"
diff --git a/testsuites/sptests/spfifo02/init.c b/testsuites/sptests/spfifo02/init.c
index 8526d0cde6..2725a5024a 100644
--- a/testsuites/sptests/spfifo02/init.c
+++ b/testsuites/sptests/spfifo02/init.c
@@ -145,11 +145,7 @@ rtems_task Init(
puts( "Creating FIFO" );
create_fifo();
-
- puts( "Opening FIFO.. expect ENFILE (semaphore @ open could not be created)" );
- open_fifo(ENFILE, O_RDWR);
- delete_semaphore();
puts( "Opening FIFO.. expect ENOMEM (semaphore for pipe could not be created)" );
open_fifo(ENOMEM, O_RDWR);