mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Simple testing task - string functions
Date: Sun, 10 Apr 2011 11:34:24 -0400	[thread overview]
Message-ID: <20110410153424.GC13185@brightrain.aerifal.cx> (raw)
In-Reply-To: <4DA1CC07.5000102@gmail.com>

On Sun, Apr 10, 2011 at 10:25:59PM +0700, JIghtuse wrote:
> I have some questions about my task. I've written a program to test
> malloc() function of musl. But..
> 1. Can I use standart rand() and srand() functions to generate
> random size of allocated memory chunks, or I must to write another
> one random number generator?

I don't mind if you use them as long as you make the default behavior
deterministic, i.e. don't seed it with time or something where we
might get a failure and then not be able to reproduce it. Or you could
use time as a seed by default if you print it so it's not lost on
failure. This is all stuff that could be changed later anyway. I just
don't want to have a situation where we saw one failure but can't
reproduce it without trying all 2billion possible seeds. :)

> Write a program which loops many times allocating and freeing memory
> 
> So, when my program must to free memory? If it freeing just after
> its allocating, it always gets one chunk of memory. And how to

If you just allocate chunk X and then free chunk X, it won't affect
fragmentation at all. You'll need to do some shuffling. There's some
code in libc-bench (see musl gitweb server) which attempts to do the
sort of random allocation patterns I have in mind, but I haven't
evaluated how good a job it actually does at fragmenting memory. You
could use it as an idea or starting point.

Or if you want to do it from scratch, read up on how hard disks get
fragmented and apply the same principles to memory.

If you're stuck, I also just thought of a simple algorithmic way to
generate fragmentation which I could explain.

> 3. I decided to generate a fragmentation diagram as a .dat file for
> plotting by gnuplot. Are you satisfied with it, or maybe write it as
> a simple text file with pseudo-graphic diagram?

Either or both would be fine.

Rich


  reply	other threads:[~2011-04-10 15:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10  4:45 Rich Felker
2011-04-10 12:08 ` Luka Marčetić
2011-04-10 15:25 ` JIghtuse
2011-04-10 15:34   ` Rich Felker [this message]
2011-04-10 15:46   ` keep discussion threads separate (was: Simple testing task - string functions) Solar Designer
2011-04-14 17:59 ` Simple testing task - string functions Luka Marčetić
2011-04-14 23:11   ` Rich Felker
2011-04-18 12:20     ` Luka Marčetić
2011-04-25 19:34     ` Unit tests Luka Marčetić
2011-04-26 19:14       ` Solar Designer
2011-04-27  0:32         ` Rich Felker
2011-04-27  0:42       ` Rich Felker
2011-04-27  6:29         ` Luka Marčetić
2011-04-29  5:36           ` Solar Designer
2011-04-29 11:54             ` Christian Neukirchen
2011-05-01 19:36               ` Solar Designer
2011-05-02  8:51                 ` Christian Neukirchen
2011-05-02 12:49                   ` Solar Designer
2011-05-02 13:02                     ` errno
2011-05-02 13:11                       ` Rich Felker
2011-05-02 13:30                         ` Solar Designer
2011-05-02 13:32                           ` Rich Felker
2011-05-02 13:52                             ` Solar Designer
2011-05-02 13:27                       ` Solar Designer

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=20110410153424.GC13185@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).