[ale] Clones and printf()
Kevin Krumwiede
krum at smyrnacable.net
Fri Mar 22 02:14:35 EST 2002
Not sure if this is completely relevant, but... I recently decided to learn
about POSIX threads, and a trip to the bookstore yielded two good books:
Programming With POSIX Threads by David R. Butenhof, and the O'Reilly
Threads book (has some larval thing on the cover... a silkworm, I think). I
chose Butenhof because it seemed a bit more comprehensive and it was only $5
more.
I've only had time to study a few chapters. I found I must unlearn Java
threads. (Or at least generalize that knowledge.)
Krum
> -----Original Message-----
> From: Chris Fowler [mailto:cfowler at outpostsentinel.com]
> Sent: Thursday, March 21, 2002 6:58 PM
> To: ale at ale.org
> Subject: RE: [ale] Clones and printf()
>
>
> I think I found one problem. Here is a snip
>
> int *stack = (int *)malloc(CHILD_STACK_SIZE); // 4096
>
> pid = clone(execTask, stack, SIGCHLD|CLONE_VM, task);
>
> The manpages states that a stack grows down. Since I'm
> passing a pointer to the begining of the stack it is possible for
> the thread to write into the parents process. Corupting my
> program. Is this correct? I looked at some sampels on the
> internet and they do not show doing that.
>
> http://www.linuxjournal.com/modules.php?op=modload&name=NS-article
> s/misc/ima
> ges&file=5211l2
>
> Maybe that example is wrong. Is there any *good* documentation
> online on using threads effectively. Maybe a book? It is just awesome
> to have multiple threads doing tasks and sharing data. It opens
> up many possibilites. I have some great planes with this.
>
>
> Thanks,
> Chris
>
> -----Original Message-----
> From: Chris Fowler [mailto:cfowler at outpostsentinel.com]
> Sent: Thursday, March 21, 2002 4:54 PM
> To: ale at ale.org
> Subject: [ale] Clones and printf()
>
>
> Hello,
>
> I've been working on a multithreaded program in which my parent keeps
> getting SIGSEGV. It appears to
> get this condition during an attempt to speak(). speak is a
> library call I
> wrote that bacially does the
> following
>
> 1) open syslog
> 2) creates a message using vsprintf
> 3) write to syslog
> 4) close syslog
>
> Each excution of speak does those things. I read in a 2001
> document that I
> should avoid
> printf's with clone. Does this still hold true? My data looks perfectly
> allocated and it does
> not appear that I have memory corruption but that could still be
> prossible.
> I basically keep
> track of drones in a linked list and keep track of tasks in a linked list.
> Each drone gets assigned 1
> task. Parent tracks the drones using the first list. drone
> keeps track of
> data only in
> the trak it is assigned. The parent and drones never write to the same
> variable. Drone
> modifies a field then parent knows to process data.
>
> Thanks,
> Chris
>
>
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info.
> Problems should be
> sent to listmaster at ale dot org.
>
>
>
>
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info.
> Problems should be
> sent to listmaster at ale dot org.
>
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list