doing save inline - Minix

This is a discussion on doing save inline - Minix ; hi i wanted to change the hwint_master macro in mpx386.s so that the call to save wasnt necessary anymore by doing all the instructions inline, but it doesnt work..compiler doesnt like the instruction following the 2: label (invalid operand); any ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: doing save inline

  1. doing save inline

    hi

    i wanted to change the hwint_master macro in mpx386.s so that the call
    to save wasnt necessary anymore by doing all the instructions inline,
    but it doesnt work..compiler doesnt like the instruction following the
    2: label (invalid operand); any ideas from your side? this it what i`ve
    done:

    #define hwint_master(irq) \

    cld ;\
    pushad ;\
    o16 push ds ;\
    o16 push es ;\
    o16 push fs ;\
    o16 push gs ;\
    mov dx, ss ;\
    mov ds, dx ;\
    mov es, dx ;\
    mov eax, esp ;\
    incb (_k_reenter) ;\
    jnz 1f ;\
    mov esp, k_stktop ;\
    push _restart ;\
    xor ebp, ebp ;\
    jmp 2f ;\
    ..align 4 ;\
    1: push restart1 ;\
    2: push (_irq_handlers+4*irq) /* irq_handlers[irq]
    */;\
    call _intr_handle /* intr_handle(irq_handlers[irq]) */;\
    pop ecx ;\
    cmp (_irq_actids+4*irq), 0 /* interrupt still active? */;\
    jz 0f ;\
    inb INT_CTLMASK /* get current mask */ ;\
    orb al, [1< outb INT_CTLMASK /* disable the irq */;\
    0: movb al, END_OF_INT
    ;\
    outb INT_CTL /* reenable master 8259 */;\
    ret

    merry christmas and thanx

    martin


  2. Re: doing save inline

    All,

    > i wanted to change the hwint_master macro in mpx386.s so that the call
    > to save wasnt necessary anymore by doing all the instructions inline,
    > but it doesnt work..compiler doesnt like the instruction following the
    > 2: label (invalid operand); any ideas from your side? this it what i`ve
    > done:
    >
    > #define hwint_master(irq) \
    >
    > cld ;\

    -snip-
    > 2: push (_irq_handlers+4*irq) /* irq_handlers[irq] */;\


    Although I can't reproduce your problem exactly, I would guess the
    preprocessor is confused by the extra blank line after the #define,
    terminating the macro, and so not recognizing 'irq' as something to
    be substituted. I'd try removing that first.

    Merry xmas everyone

    =Ben



  3. Re: doing save inline

    Hi Ben
    Ben Gras schrieb:

    > Although I can't reproduce your problem exactly, I would guess the
    > preprocessor is confused by the extra blank line after the #define,
    > terminating the macro, and so not recognizing 'irq' as something to
    > be substituted. I'd try removing that first.


    I'd not have thought the cause of my problem was sio trivial but that
    was it, thanx...it's an exercise in the minix 3 book. It goes on by
    asking "Can you measure a performance increase by doing save
    inline"..Do you have an idea how I could possibly measure that?
    thanx,
    martin


  4. Re: doing save inline

    The "save" part is macro but not assembly language.
    That means preprocessor replaced the lines of code with assembly and
    then machine language code.

    That question is about how much difference they have when the
    statements are used using compiler or direct assembly language is used,
    and furthermore how much the lowest part of kernel part should work as
    fast as possible without any overhead.But the code uses different
    separate "save"-function like statements using the complier which
    creates much more overhead.

    An idea is simple but extreamely tricky. You need a full understanding
    of theory and start looking closely at the lines of code before you
    modify the code or otherwise it would be easy to be able to make you
    much frustrated.You need understand line by line what it means exactly
    and what it is used for.It is a just tip.

    You could call a C-language function from there. or you could add
    assembly language lines between them.





    sancho1980 wrote:
    > Hi Ben
    > Ben Gras schrieb:
    >
    > > Although I can't reproduce your problem exactly, I would guess the
    > > preprocessor is confused by the extra blank line after the #define,
    > > terminating the macro, and so not recognizing 'irq' as something to
    > > be substituted. I'd try removing that first.

    >
    > I'd not have thought the cause of my problem was sio trivial but that
    > was it, thanx...it's an exercise in the minix 3 book. It goes on by
    > asking "Can you measure a performance increase by doing save
    > inline"..Do you have an idea how I could possibly measure that?
    > thanx,
    > martin



  5. Re: doing save inline

    The "save" part is macro but not assembly language.
    That means preprocessor would replace the lines of code with assembly
    and
    then machine language code.

    That question is about how much difference they have when the
    statements are used using compiler or direct assembly language is used,
    and furthermore how much the lowest part of kernel part should work as
    fast as possible without any overhead.But the code uses different
    separate "save"-function like statements using the complier which
    creates much more overhead.

    An idea is simple but extreamely tricky. You need a full understanding
    of theory and start looking closely at the lines of assembly code
    before you
    modify the code or otherwise it would be easy to be able to make you
    much frustrated.You need understand line by line what it means exactly
    and what it is used for.It is a just tip.

    You could call a C-language function from there. or you could add
    assembly language lines between them after they are modified with
    in-line statements

    I hope you have a fun and good luck

    sancho1980 wrote:
    > Hi Ben
    > Ben Gras schrieb:
    >
    > > Although I can't reproduce your problem exactly, I would guess the
    > > preprocessor is confused by the extra blank line after the #define,
    > > terminating the macro, and so not recognizing 'irq' as something to
    > > be substituted. I'd try removing that first.

    >
    > I'd not have thought the cause of my problem was sio trivial but that
    > was it, thanx...it's an exercise in the minix 3 book. It goes on by
    > asking "Can you measure a performance increase by doing save
    > inline"..Do you have an idea how I could possibly measure that?
    > thanx,
    > martin



  6. Re: doing save inline

    The "save" part is called using the function call mechanism which
    brings about some overhead

    That question is about how much difference they have when the
    statements are used using compiler(function call mechanism) or direct
    assembly language is used,and furthermore how much the lowest part of
    kernel part should work as
    fast as possible without any overhead.But the code uses different
    separate "save"-function like statements using the complier which
    creates much more overhead.

    An idea is simple but extreamely tricky. You need a full understanding
    of theory and start looking closely at the lines of assembly code
    before you modify the code or otherwise it would be easy to be able to
    make you
    much frustrated.You need understand line by line what it means exactly
    and what it is used for.It is a just tip.

    You could call a C-language function from there. or you could add
    assembly language lines between them after they are modified with
    in-line statements following fully understanding them.

    I hope you have a fun and good luck.

    tmK

    sancho1980 wrote:
    > Hi Ben
    > Ben Gras schrieb:
    >
    > > Although I can't reproduce your problem exactly, I would guess the
    > > preprocessor is confused by the extra blank line after the #define,
    > > terminating the macro, and so not recognizing 'irq' as something to
    > > be substituted. I'd try removing that first.

    >
    > I'd not have thought the cause of my problem was sio trivial but that
    > was it, thanx...it's an exercise in the minix 3 book. It goes on by
    > asking "Can you measure a performance increase by doing save
    > inline"..Do you have an idea how I could possibly measure that?
    > thanx,
    > martin



  7. Re: doing save inline

    All,

    On 26 Dec 2006 05:14:30 -0800, sancho1980 wrote:
    > It goes on by asking "Can you measure a performance increase by doing
    > save inline"..Do you have an idea how I could possibly measure that?


    I would suggest using the 'rdtsc' instruction to measure the number
    of cycles spent in each case, taking care not to clobber the registers,
    and to measure the number of cycles it takes to do this measurement and
    saving of registers if necessary.

    'rdtsc' is available on pentiums and up. The ack assembler doesn't know
    it, so you'll have to use a trick to execute it. An example of that is
    in _read_tsc in klib386.s.

    Also, you could try a real-world test to see how much difference it
    really makes; after all, even if you find this saves 10% of all cycles,
    that might not necessarily matter. Try doing a real-world test, such as
    a big compile batch or a compile in a loop, or a cpu-intensive program
    in a loop, with and without the inline optimization, and see how much
    the time difference is.

    Good luck!

    =Ben



  8. Re: doing save inline

    HI sancho1980

    I think the paper of 'A Port of the MINIX OS to the PowerPC Platform*
    (Ingmar Alting's Masters thesis) ' would be helpful of how to get
    access to it if you reference with it, which has been posted on
    http://www.minix3.org/doc/

    tmK

    sancho1980 wrote:
    > Hi Ben
    > Ben Gras schrieb:
    >
    > > Although I can't reproduce your problem exactly, I would guess the
    > > preprocessor is confused by the extra blank line after the #define,
    > > terminating the macro, and so not recognizing 'irq' as something to
    > > be substituted. I'd try removing that first.

    >
    > I'd not have thought the cause of my problem was sio trivial but that
    > was it, thanx...it's an exercise in the minix 3 book. It goes on by
    > asking "Can you measure a performance increase by doing save
    > inline"..Do you have an idea how I could possibly measure that?
    > thanx,
    > martin



+ Reply to Thread