Re: Appendix: multithreating HOWTO ? :)

£ukasz wrote:
> 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
You are using fork. Fork is used to create new processes.
You probably want clone instead, to create new threads and specify
which resources to share between the two threads.
man 2 clone
sys_clone is 120 (0x78).
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Appendix: multithreating HOWTO ? :)

On Sun, Aug 23, 2009 at 5:04 PM, Frank Kotler<fbkotler <at> zytor.com> wrote:
> Claudio Fontana wrote:
>>
>> Łukasz wrote:
>>>
>>> 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
>>
>> You are using fork. Fork is used to create new processes.
>> You probably want clone instead, to create new threads and specify
>> which resources to share between the two threads.
>>
>> man 2 clone
>>
>> sys_clone is 120 (0x78).
>
> Is that a 64-bit sys_call number? I thought they'd changed that on us.
> AFAIK, __NR_clone is 56 these days... and "syscall" replaces int 0x80. A
> real "curve ball" to asm programmers! Well, they *told* us not to do it that
> way. :)
>
> Best,
> Frank
I am still on good old 32bit. On 64 bit system call numbers are indeed
completely different.
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org

Re: Appendix: multithreating HOWTO ? :)

Frank Kotler <fbkotler <at> zytor.com>
2009-08-23 15:04:46 GMT

Claudio Fontana wrote:
> £ukasz wrote:
>> 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
>
> You are using fork. Fork is used to create new processes.
> You probably want clone instead, to create new threads and specify
> which resources to share between the two threads.
>
> man 2 clone
>
> sys_clone is 120 (0x78).
Is that a 64-bit sys_call number? I thought they'd changed that on us.
AFAIK, __NR_clone is 56 these days... and "syscall" replaces int 0x80. A
real "curve ball" to asm programmers! Well, they *told* us not to do it
that way. :)
Best,
Frank
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Appendix: multithreating HOWTO ? :)

Frank Kotler <fbkotler <at> zytor.com>
2009-08-23 19:18:48 GMT

£ukasz wrote:
> thanks for answer, im experiment with system clone ( actualy fork i found in many manuals ) but i dont
understand Frakns last sentence
> "Well, they *told* us not to do it that way. :)", to program multiproceses with fork ? Any way is there any way
to make share memory for proceses ?
Just a "joke". I meant, using the int 80h (or syscall) interface. We're
"supposed" to use the C interface.
Like Claudio, I'm a "32-bit guy" - and I don't know how to do
multithreading even on 32-bit. But I think if you're going to use 64-bit
registers, you'll have to use 64-bit sys_call numbers, put the
parameters in regs compatible with the 64-bit ABI, and use "syscall"
instead of "int 0x80". I don't think what you're doing will work, but
I'm not equipped to try it.
You can share memory between processes by memmapping a region and
flagging it MAP_SHARED (sys_fork or even separate executables). I
*think* for threads, you'd want sys_clone, and all memory would be
shared(?). I think your issue is going to be keeping your threads from
read/writing the same memory at the same time. I'm a "single CPU guy",
too, but I think multi-CPU is going to be "even worse".
I made an example using pthread_create - not that I want to use it
either, but to see what it does for us. Easier to read the source, I'm
sure, but no, I ran it in strace. Doing a bunch of "signal related"
stuff I don't understand. I'm afraid I'm going to have to learn more
about "signals" before I can proceed with this...
For those of us who need to learn about 64-bit programming, there's a

Re: Appendix: multithreating HOWTO ? :)

On Sunday 23 August 2009 09:17:59 £ukasz wrote:
> thanks for answer, im experiment with system clone ( actualy fork i found
> in many manuals ) but i dont understand Frakns last sentence "Well, they
> *told* us not to do it that way. :)", to program multiproceses with fork ?
> Any way is there any way to make share memory for proceses ?i
There are several ways to do shared memory. If using a "fork"
the asmlib functions:
shared_open
shared_attach
shared_close
provide some example code.
see http://linuxasmtools.net download asmlib and look memory funcitons.
all the best, jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html