Appendix: multithreating HOWTO ? :)

£ukasz <[email protected]> Sun, 23 Aug 2009 03:29:15 -0700 (PDT)
Newsgroups org.kernel.vger.linux-assembly
Message-ID <[email protected]>
in appendix i want to just precize problem. Broblem is how to write, create etc, shared memory for parent and child proceses, where they could for example exchange wariables

--- On Sat, 8/22/09, £ukasz <[email protected]> wrote:

> From: £ukasz <[email protected]>
> Subject: multithreating HOWTO ? :)
> To: [email protected]
> Date: Saturday, August 22, 2009, 6:48 PM
> Hi All.
> I'm trying to start writing multithread programs with
> assembler (no pthreads), i want to just ask what is wrong in
> folowing simple code:
> 
> 
> .section .data
> 
> signal1:
> .quad    1
> 
> signal2:
> .quad    1
> 
> x:
> .quad    0
> 
> y:
> .quad    0
> 
> .section .text
> .globl _start
> _start:
>     nop
>     movq    $2,%rax   
>        # sys_fork
>     xorq    %rbx,%rbx
>     int       
> $0x80
>     
>     cmpq    $0,%rax
>     jl        end
>     
>     cmpq    $0,%rax
>     jg       
> parent            # jump if
> parent
>     
> 
> child:
>     movq    $100,x
>     movq    $0,signal1
> 
> 1:    
>     cmpq    $0,signal2
>     jnz        1b
>     jmp     end
> 
> 
> parent:
>     movq    $100,y
>     movq    $0,signal2
> 
> 1:    
>     cmpq    $0,signal1
>     jnz       
> 1b            # INF. LOOP ?
>     
> end:
>     movq        x,%rbx
>     addq        y,%rby
>     movq    $1,%rax
>     int       
> $0x80
> 
> Program stacks at parent part in infinite loop waiting for
> "signal1" change to 0. Anybody knows how to write it
> properly with using two threads? Thanks in advance.
> 
> Lukas
> 
> 
>       
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-assembly" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


      
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html