Hello Stephen,

Am 2011-04-03 15:00:03, schrieb Stephen McCamant <s...@csail.mit.edu>
> SJR> the system I'm working on does not have swap space (for a
> SJR> reason), yet xmem still switches to include a horizontal line for
> SJR> the physical/swap boundary. Obviously, the upper half is empty;
> SJR> it even switches back sometimes. This appears to be a "slightly
> SJR> above 100%" condition due to rounding errors.
> 
> I've been annoyed by this too. It's possible that a rounding problem
> could cause this behavior in some circumstances, though I think the
> height calculation uses "1.0 + swap", so if swap is exactly 0 the
> result should be exactly 1.0. On machines with swap space it can also
> happen that Linux uses a very small but non-zero amount of swap, but
> in looking at the code today I noticed there's also a bug that causes
> this even in the absence of those. When the chart is redrawn in
> response to an exposure event, the code that recomputes the integer
> scale "rounds" using the equivalent of "floor(x) + 1" instead of
> "ceil(x)", so if the floating-point "maximum height seen" is exactly
> 1.0, it will be rounded to 2. (This code is on line 400 of
> MemStripChart.c in the etch 1.20-25 source, in the function
> repaint_window).
> 
> Using ceil() to do the rounding would probably fix your version of the
> problem. I think the best fix, though, might be to change the
> calculation to "ceil(x - epsilon)", where epsilon is chosen to be
> about the amount that would show up as a single pixel in the display:
> in other words, we don't want to increase the scale unless there would
> actually be some swap usage visible.

----[ '/Development/xmem/xmem-1.20/MemStripChart.c' ]-------------------
<snip>
static int 
repaint_window(w, left, width)
    MemStripChartWidget w;
    int left, width;
{
    int i, j;
    int next = w->mem_strip_chart.interval;
    int scale = w->mem_strip_chart.scale;
    int scalewidth = 0;

    /* Compute the minimum scale required to graph the data, but don't go
       lower than min_scale. */
    if (w->mem_strip_chart.interval != 0 || scale <= 
(int)w->mem_strip_chart.max_value)
        scale = ((int) (w->mem_strip_chart.max_value)) + 1;
------------------------------------------------------------------------

So this is line 400 but I do not understand what to change...  :-/

I have searched for ceil() or ceiling() but not found it.
Which header must I ad to get it?

------------------------------------------------------------------------
    if (scale < w->mem_strip_chart.min_scale)
        scale = w->mem_strip_chart.min_scale;

    if (scale != w->mem_strip_chart.scale) {
        w->mem_strip_chart.scale = scale;
        left = 0;
        width = next;
        scalewidth = w->core.width;

        SetPoints(w);

        if (XtIsRealized ((Widget) w)) 
            XClearWindow (XtDisplay (w), XtWindow (w));

    }

    if (XtIsRealized((Widget)w)) {
        Display *dpy = XtDisplay(w);
        Window win = XtWindow(w);

        width += left - 1;
        if (!scalewidth) scalewidth = width;

        if (next < ++width) width = next;

        /* Draw data point lines. */
        for (i = left; i < width; i++) {
            DrawMemStrip(w, i, w->mem_strip_chart.valuedata[i]);
        }

        /* Draw graph reference lines */
        for (i = 1; i < w->mem_strip_chart.scale; i++) {
            j = i * ((int)w->core.height / w->mem_strip_chart.scale);
            XDrawLine(dpy, win, w->mem_strip_chart.hiGC, left, j, scalewidth, 
j);
        }
    }
    return(next);
}
<snip>
------------------------------------------------------------------------

>  -- Stephen

Thanks, Greetings and nice Day/Evening
    Michelle Konzack

-- 
##################### Debian GNU/Linux Consultant ######################
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsystems@tdnet France EURL       itsystems@tdnet UG (limited liability)
Owner Michelle Konzack            Owner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz                 Kinzigstraße 17
67100 Strasbourg/France           77694 Kehl/Germany
Tel: +33-6-61925193 mobil         Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

<http://www.itsystems.tamay-dogan.net/>  <http://www.flexray4linux.org/>
<http://www.debian.tamay-dogan.net/>         <http://www.can4linux.org/>

Jabber linux4miche...@jabber.ccc.de

Linux-User #280138 with the Linux Counter, http://counter.li.org/

Attachment: signature.pgp
Description: Digital signature

Reply via email to