From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/264 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Simple testing task - string functions Date: Sun, 10 Apr 2011 11:34:24 -0400 Message-ID: <20110410153424.GC13185@brightrain.aerifal.cx> References: <20110410044515.GB13185@brightrain.aerifal.cx> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1312595693 11342 80.91.229.12 (6 Aug 2011 01:54:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 01:54:53 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: envelope-from@hidden Sun Apr 10 19:39:12 2011 Content-Disposition: inline In-Reply-To: <4DA1CC07.5000102@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:264 Archived-At: 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