2002-03-25 Eric Norum <norume@aps.anl.gov>

PR 374/networking
	* Makefile.am, rtems/rtems_bsdnet.h, rtems/rtems_glue.c:
	The patch sent as part of PR270 got applied to the wrong place.
	The effect was that (1) startup was no faster than before and
	(2) malloc starvation messages came way too quickly.  The attached
	patch fixes both these problems and also provides a mechanism for
	applications to handle malloc starvation conditions as they see fit.
	* rtems/rtems_bsdnet_malloc_starvation.c: New file.
This commit is contained in:
Joel Sherrill
2003-03-25 19:00:23 +00:00
parent b7985c50a6
commit 593616a8db
5 changed files with 41 additions and 5 deletions

View File

@@ -1,3 +1,15 @@
2002-03-25 Eric Norum <norume@aps.anl.gov>
PR 374/networking
* Makefile.am, rtems/rtems_bsdnet.h, rtems/rtems_glue.c:
The patch sent as part of PR270 got applied to the wrong place.
The effect was that (1) startup was no faster than before and
(2) malloc starvation messages came way too quickly. The attached
patch fixes both these problems and also provides a mechanism for
applications to handle malloc starvation conditions as they see fit.
* rtems/rtems_bsdnet_malloc_starvation.c: New file.
2003-03-18 Till Straumann <strauman@slac.stanford.edu> 2003-03-18 Till Straumann <strauman@slac.stanford.edu>
PR 356/bsps PR 356/bsps
@@ -123,6 +135,7 @@
directives. directives.
2002-12-18 Eric Norum <eric.norum@usask.ca> 2002-12-18 Eric Norum <eric.norum@usask.ca>
* Makefile.am: Include netinet sources. * Makefile.am: Include netinet sources.
2002-12-12 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2002-12-12 Ralf Corsepius <corsepiu@faw.uni-ulm.de>

View File

@@ -159,7 +159,8 @@ PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems \
rtems_C_FILES = rtems/sghostname.c rtems/issetugid.c rtems/rtems_glue.c rtems/rtems_syscall.c \ rtems_C_FILES = rtems/sghostname.c rtems/issetugid.c rtems/rtems_glue.c rtems/rtems_syscall.c \
rtems/rtems_bootp.c rtems/rtems_showmbuf.c rtems/rtems_showroute.c rtems/rtems_showifstat.c \ rtems/rtems_bootp.c rtems/rtems_showmbuf.c rtems/rtems_showroute.c rtems/rtems_showifstat.c \
rtems/rtems_showipstat.c rtems/rtems_showicmpstat.c rtems/rtems_showtcpstat.c \ rtems/rtems_showipstat.c rtems/rtems_showicmpstat.c rtems/rtems_showtcpstat.c \
rtems/rtems_showudpstat.c rtems/rtems_select.c rtems/mkrootfs.c rtems/rtems_showudpstat.c rtems/rtems_select.c rtems/mkrootfs.c \
rtems/rtems_bsdnet_malloc_starvation.c
OBJS += $(rtems_C_FILES:rtems/%.c=$(ARCH)/%.$(OBJEXT)) OBJS += $(rtems_C_FILES:rtems/%.c=$(ARCH)/%.$(OBJEXT))
$(ARCH)/%.$(OBJEXT): rtems/%.c $(ARCH)/%.$(OBJEXT): rtems/%.c

View File

@@ -182,4 +182,11 @@ void rtems_bsdnet_do_bootp_and_rootfs (void);
int rtems_bsdnet_synchronize_ntp (int interval, rtems_task_priority priority); int rtems_bsdnet_synchronize_ntp (int interval, rtems_task_priority priority);
/*
* Callback to report BSD malloc starvation.
* The default implementation just prints a message but an application
* can provide its own version.
*/
void rtems_bsdnet_malloc_starvation(void);
#endif /* _RTEMS_BSDNET_ */ #endif /* _RTEMS_BSDNET_ */

View File

@@ -0,0 +1,15 @@
/*
* Routine called when malloc() is not succeeding. This can be overridden
* by a BSP.
*
* $Id*
*/
#include <stdio.h>
#include <rtems_bsdnet.h>
void
rtems_bsdnet_malloc_starvation(void)
{
printf ("rtems_bsdnet_malloc still waiting.\n");
}

View File

@@ -117,11 +117,10 @@ rtems_bsdnet_malloc (unsigned long size, int type, int flags)
return p; return p;
rtems_bsdnet_semaphore_release (); rtems_bsdnet_semaphore_release ();
if (++try >= 30) { if (++try >= 30) {
printf ("rtems_bsdnet_malloc still waiting.\n"); rtems_bsdnet_malloc_starvation();
try = 0; try = 0;
} }
while (rtems_bsdnet_seconds_since_boot() == 0) rtems_task_wake_after (rtems_bsdnet_ticks_per_second);
rtems_task_wake_after(1);
rtems_bsdnet_semaphore_obtain (); rtems_bsdnet_semaphore_obtain ();
} }
} }
@@ -272,7 +271,8 @@ rtems_bsdnet_initialize (void)
/* /*
* Ensure that `seconds' is greater than 0 * Ensure that `seconds' is greater than 0
*/ */
rtems_task_wake_after (rtems_bsdnet_ticks_per_second); while (rtems_bsdnet_seconds_since_boot() == 0)
rtems_task_wake_after(1);
/* /*
* Set up BSD-style sockets * Set up BSD-style sockets