Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #21006

Re: working with big numbers

From jgk@panix.com (Joe keane)
Newsgroups comp.lang.c
Subject Re: working with big numbers
Date 2012-05-18 21:57 +0000
Organization Public Access Networks Corp.
Message-ID <jp6gjk$eqt$1@reader1.panix.com> (permalink)
References <ee0f80bf-1b3c-4996-a6db-64ecb396cdb7@rn12g2000pbb.googlegroups.com> <joto72$1ua$1@dont-email.me> <7761083.2431.1337247739694.JavaMail.geo-discussion-forums@vbvq7> <pan.2012.05.17.17.43.13.654000@nowhere.com>

Show all headers | View raw


In article <pan.2012.05.17.17.43.13.654000@nowhere.com>,
Nobody  <nobody@nowhere.com> wrote:
>Also, heap allocation failure is usually easier to catch than stack
>allocation failure.

If you are writing code that is supposed to be reliable, it's much
better.  Check for no-mem, if so, clean up and report 'we're sorry, we
are unable to fulfill your request at this time'; or get SEGV...

well great now you screwed up the shared memory too

...

So this one time, some customer had a problem, they were running
thousands of threads and their requirements for stack were tight.

Then i found the problem:

    int smash_page(PAGE *page)
    {
	PAGE tmppage;

	...(page, tmppage)...

	memcpy(page, &tmppage, sizeof PAGE);
    }

Perfectly sensible, but when i switched it to use heap their problem
fixed itself.  I confirmed that the run-time was negligible.

For multi-thread, heap memory needs as much memory as is needed at one
time, while stack memory needs as much memory as all of them will need
at some time.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

working with big numbers ashu <ashishmourya21@gmail.com> - 2012-05-13 08:42 -0700
  Re: working with big numbers thomas.mertes@gmx.at - 2012-05-13 09:48 -0700
    Re: working with big numbers Ike Naar <ike@sverige.freeshell.org> - 2012-05-15 07:19 +0000
      Re: working with big numbers Nils M Holm <news2009@t3x.org> - 2012-05-15 07:56 +0000
        Re: working with big numbers Ike Naar <ike@sverige.freeshell.org> - 2012-05-15 14:11 +0000
  Re: working with big numbers thomas.mertes@gmx.at - 2012-05-13 10:00 -0700
  Re: working with big numbers Barry Schwarz <schwarzb@dqel.com> - 2012-05-14 15:53 -0700
  Re: working with big numbers bl0ckedusersoft@gmail.com - 2012-05-14 13:11 -0700
    Re: working with big numbers Noob <root@127.0.0.1> - 2012-05-15 11:37 +0200
      Re: working with big numbers Bl0ckeduser <bl0ckedusersoft@gmail.com> - 2012-05-15 10:11 -0400
        Re: working with big numbers nick_keighley_nospam@hotmail.com - 2012-05-17 02:42 -0700
          Re: working with big numbers Nobody <nobody@nowhere.com> - 2012-05-17 18:43 +0100
            Re: working with big numbers jgk@panix.com (Joe keane) - 2012-05-18 21:57 +0000
          Re: working with big numbers Bl0ckeduser <bl0ckedusersoft@gmail.com> - 2012-05-17 17:44 -0400
    Re: working with big numbers Peter Nilsson <airia@acay.com.au> - 2012-05-16 15:38 -0700
      Re: working with big numbers Bl0ckeduser <bl0ckedusersoft@gmail.com> - 2012-05-16 22:01 -0400
  Re: working with big numbers Paul <nospam@needed.com> - 2012-05-14 19:44 -0400
  Re: working with big numbers Robert Miles <robertmilesxyz@gmail.com> - 2012-05-14 18:16 -0700
  Re: working with big numbers Ike Naar <ike@sverige.freeshell.org> - 2012-05-15 06:50 +0000
  Re: working with big numbers Nils M Holm <news2009@t3x.org> - 2012-05-15 07:06 +0000
  Re: working with big numbers James Dow Allen <jdallen2000@yahoo.com> - 2012-05-15 02:13 -0700
    Re: working with big numbers Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-05-15 11:07 +0100
      Re: working with big numbers Nils M Holm <news2009@t3x.org> - 2012-05-15 11:10 +0000
        Re: working with big numbers Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-05-15 15:03 +0100
          Re: working with big numbers Bl0ckeduser <bl0ckedusersoft@gmail.com> - 2012-05-15 10:34 -0400
  Re: working with big numbers Edwin van den Oetelaar <newsgroups@oetelaar.com> - 2012-05-17 13:14 +0200
    Re: working with big numbers "BartC" <bc@freeuk.com> - 2012-05-17 12:34 +0100

csiph-web