so I expected that theses three threads execute in parallel,and therfore in
I expected to have mixed displays of threads in terminal .but after the execution I have a regular display of threads,i.e. thread 1 prints all its
while loop(from 1 to 9),after thread 2 ,and after thread3 it seems that there
is no parallel execution of these threads,I try to increase the number
of iteration of loop while to 100 but nothing changes.
Any thoughts?
(I am using a multiprocessor machine and Kubuntu)
here is example of the execution:
THREAD # 0
******************
******************
in loop while k=1 :
in loop for j=0 :
THREAD # 0
******************
******************
in loop while k=2 :
in loop for j=0 :
THREAD # 0
******************
******************
in loop while k=3 :
in loop for j=0 :
THREAD # 0
******************
******************
in loop while k=4 :
in loop for j=0 :
in loop for j=3 :
THREAD # 0
******************
******************
in loop while k=5 :
in loop for j=0 :
in loop for j=3 :
THREAD # 0
******************
******************
in loop while k=6 :
in loop for j=0 :
in loop for j=3 :
THREAD # 0
******************
******************
in loop while k=7 :
in loop for j=0 :
in loop for j=3 :
in loop for j=6 :
THREAD # 0
******************
******************
in loop while k=8 :
in loop for j=0 :
in loop for j=3 :
in loop for j=6 :
THREAD # 0
******************
******************
in loop while k=9 :
in loop for j=0 :
in loop for j=3 :
in loop for j=6 :
THREAD # 1
******************
******************
in loop while k=1 :
THREAD # 1
******************
******************
in loop while k=2 :
in loop for j=1 :
THREAD # 1
******************
******************
in loop while k=3 :
in loop for j=1 :
THREAD # 1
******************
******************
in loop while k=4 :
in loop for j=1 :
THREAD # 1
******************
******************
in loop while k=5 :
in loop for j=1 :
in loop for j=4 :
THREAD # 1
******************
******************
in loop while k=6 :
in loop for j=1 :
in loop for j=4 :
THREAD # 1
******************
******************
in loop while k=7 :
in loop for j=1 :
in loop for j=4 :
THREAD # 1
******************
******************
in loop while k=8 :
in loop for j=1 :
in loop for j=4 :
in loop for j=7 :
THREAD # 1
******************
******************
in loop while k=9 :
in loop for j=1 :
in loop for j=4 :
in loop for j=7 :
THREAD # 2
******************
******************
in loop while k=1 :
THREAD # 2
******************
******************
in loop while k=2 :
THREAD # 2
******************
******************
in loop while k=3 :
in loop for j=2 :
THREAD # 2
******************
******************
in loop while k=4 :
in loop for j=2 :
THREAD # 2
******************
******************
in loop while k=5 :
in loop for j=2 :
THREAD # 2
******************
******************
in loop while k=6 :
in loop for j=2 :
in loop for j=5 :
THREAD # 2
******************
******************
in loop while k=7 :
in loop for j=2 :
in loop for j=5 :
THREAD # 2
******************
******************
in loop while k=8 :
in loop for j=2 :
in loop for j=5 :
THREAD # 2
******************
******************
in loop while k=9 :
in loop for j=2 :
in loop for j=5 :
in loop for j=8 :
Thanks,
B.
Last edited by Franklin52; 04-29-2009 at 06:29 PM..
Reason: adding code tags
First, please put [code ][/code] tags (sans the space) around your listing, it's easier on the eyes. And since we're on the subject, could you shorten your output?
Second: Your thread has to run 8 printf()s, which translates to about 25 system instructions, times 10 = 250 instructions. Given that even a P90 from the last century can do roughly 90000000 instructions per second, your code is done long before the kernel has any reason to preempt it.
Hi,
I have a VM with following configration .
3.10.0-693.1.1.el7.x86_64 #1 SMP Thu Aug 3 08:15:31 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
My current POSIX is :--
Your environment variables take up 2011 bytes
POSIX upper limit on argument length (this system): 2093093
POSIX smallest... (15 Replies)
I wonder if someone knows what is the rationale behind linking function calls of the POSIX threads library at link-time vs. run-time.
For example, if I create the following program:
#include <pthread.h>
void noop() {
return;
}
int main() {
pthread_self();
pthread_atfork(noop,... (1 Reply)
Hi,
I am new to posix threads. The no of threads to be created depends on the runtime. If I get the number of threads,
I need to forward declare
pthread_t mythread;
how to do that can I use pointers and use malloc()??
I also have another question. The pthread_join is used to make... (0 Replies)
I created multiple POSIX threads (on readhat Linux) in a C program in my app. What I am doing is - I am creating threads equal to the number of CPUs in the system and and equal number of instances of a certain data structure, basically a queue implementation. I am assigning one ID to the thread... (2 Replies)
HI,
When i am configuring php in SUN Solaris. I am getting the below error.
configure: error: Your system seems to lack POSIX threads.
Do i need to install POSIX? If so can somebody let me know where can i download POSIX for Solaris 8?
Thanks, (2 Replies)
Hi all,
How can I get the list of all Threads and the Total count of threads under a particular process ?
Do suggest !!
Awaiting for the replies !!
Thanks
Varun:b: (2 Replies)
Hello !
Let's supose I have a main function in C , and two POSIX threads. I give you an example down :
int main() {
int something;
char else;
void *FirstThread();
void *SecondThread();
..
<start those two pthreads ..>
return 0;}
void *FirstThread() { ... }
void *SecondThread()... (2 Replies)