public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ihar 'Philips' Filipau" <filia@softhome.net>
To: root@chaos.analogic.com
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: 2.2/2.4/2.6 VMs: do malloc() ever return NULL?
Date: Wed, 26 Nov 2003 15:39:55 +0100	[thread overview]
Message-ID: <3FC4BB3B.7010109@softhome.net> (raw)
In-Reply-To: <Pine.LNX.4.53.0311260829340.9730@chaos>

Richard B. Johnson wrote:
> 
> Here is a dynamic allocation scheme that doesn't fail with
> the usual, i.e., less that 1/2 megabyte temporary storage. It
> also automatically frees the RAM it's allocated.
> 
> int function(void *what, size_t len)
> {
>     char tmp[len];
>     ;;;;;
>     return 0;
> }
> 

    You want to say that space is always allocated?
    And how can you make graceful error handling if there is no memory left?
    malloc() has return value, mlock() has return value. So there is at 
least room for error handling. But in your case if you will by mistake 
will run second instance of application - what will happend? I suppose 
crash or welcome oom_killer. Both not nice.

> 
> If you need really large buffers and have only a single
> thread, you can still allocate memory at compile-time, i.e.,
> 
> char scratch[0x10000000];
> 

   I was thinking about this - it has a lot of adavantages and one very 
big disadvantage: you need to recompile app to scale system, you cannot 
make this a command line/configuration parameter.

> 
>>   Embedded? with swap?!?
>>   What you have smoken?! - take me to your dealer!-)))
>>
> 
> Absolutely. A RAM-Disk on non-paged RAM. It allows individual
> tasks to keep track of a valuable resource with minimum
> overhead. It would be nicer if there was a "get free pages"
> function call but you can make a driver for a virtual device
> that returns such information. Then you don't need the
> RAM disk to keep track of virtual memory
> 

   A-ha. A la mtd/rw flash.
   Intersting idea.

   Let's say: I'm working on embedded system - but it is less embedded 
than other embedded systems ;-)

   Thanks for your advices in any way - probably something can be used 
in future.

-- 
Ihar 'Philips' Filipau  / with best regards from Saarbruecken.
--                                                           _ _ _
  Because the kernel depends on it existing. "init"          |_|*|_|
  literally _is_ special from a kernel standpoint,           |_|_|*|
  because its' the "reaper of zombies" (and, may I add,      |*|*|*|
  that would be a great name for a rock band).
                                 -- Linus Torvalds


  reply	other threads:[~2003-11-26 14:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-25 13:27 2.2/2.4/2.6 VMs: do malloc() ever return NULL? Ihar 'Philips' Filipau
2003-11-25 14:00 ` Arjan van de Ven
2003-11-25 16:58 ` Rik van Riel
2003-11-25 19:03   ` Ihar 'Philips' Filipau
2003-11-25 19:24     ` Rik van Riel
2003-11-25 19:28     ` Chris Wright
2003-11-25 20:17 ` Richard B. Johnson
2003-11-25 23:17   ` Ihar 'Philips' Filipau
2003-11-25 23:40     ` Oliver
2003-11-26 13:06     ` Richard B. Johnson
2003-11-26 13:20       ` Ihar 'Philips' Filipau
2003-11-26 13:27         ` William Lee Irwin III
2003-11-26 14:33           ` Ihar 'Philips' Filipau
2003-11-26 14:36             ` William Lee Irwin III
2003-11-26 13:49         ` Richard B. Johnson
2003-11-26 14:39           ` Ihar 'Philips' Filipau [this message]
2003-11-26  7:31   ` Tim Connors
2003-11-26  9:58     ` William Lee Irwin III
     [not found] <VLAm.2g1.9@gated-at.bofh.it>
     [not found] ` <VM3n.3jY.9@gated-at.bofh.it>
2003-11-25 15:23   ` Ihar 'Philips' Filipau
     [not found] <VQJL.62Q.11@gated-at.bofh.it>
     [not found] ` <VR3c.6Ns.21@gated-at.bofh.it>
2003-11-26 10:30   ` Ihar 'Philips' Filipau
2003-11-26 10:39     ` William Lee Irwin III
2003-11-26 12:14       ` Ihar 'Philips' Filipau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FC4BB3B.7010109@softhome.net \
    --to=filia@softhome.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox