threading

A

Aloo

hi everybody,

I was recently trying theading in c on linux using the standard
threading library. It was a small program for printing a sequence of
numbers.

I encountered 2 problems

1) Each process completed its entire operation the moment it was
called. The output I got was 01234567891023456789 whereas I was
expecting 00112233445566778899. Is it due to that the process was so
small that it finished in the time slice alotted it OR is there any
other reason. Can I get the output I expected from it without insertion
of delays.

2) I was earlier using printf but ws getting the output at the end of
process completion even with delay in place. Later I got to know that
'printf' does not have re-entrant code. I want to know why is it
required? and how does it make the program work differently ?
 
W

Walter Roberson

I was recently trying theading in c on linux using the standard
threading library. It was a small program for printing a sequence of
numbers.
I encountered 2 problems

comp.lang.c devotes itself to standard C. Questions about threads
are best addressed to a newsgroup that deals with threads (which
are not part of standard C).

1) Each process completed its entire operation the moment it was
called. The output I got was 01234567891023456789 whereas I was
expecting 00112233445566778899. Is it due to that the process was so
small that it finished in the time slice alotted it OR is there any
other reason. Can I get the output I expected from it without insertion
of delays.
2) I was earlier using printf but ws getting the output at the end of
process completion even with delay in place. Later I got to know that
'printf' does not have re-entrant code. I want to know why is it
required? and how does it make the program work differently ?

When you post to the appropriate thread-related newsgroup, you
should include code samples showing how the values were produced.
The behaviour you describe could have a number of different causes.
I could list my top 83 speculations, but it would be much less work
all around if you were to post code in an appropriate newsgroup.
 
K

Keith Thompson

Aloo said:
I was recently trying theading in c on linux using the standard
threading library. It was a small program for printing a sequence of
numbers.

Try comp.programming.threads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top