10-10-2014
Quote:
Originally Posted by
DaveX
But unfortunately I have still the same behavior with the counting of the generated words.
Why are you printing
count? Why do you even have
count? Print
flag! That's what it's there for.
Finally, it's unavoidable when doing a parallel search that you may run more threads than strictly necessary. If you ran 4 simultaneous threads but found it on the very first try, that's tough luck, you ran 4 anyway.
Last edited by Corona688; 10-10-2014 at 07:08 PM..
This User Gave Thanks to Corona688 For This Post:
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello,
I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies
2. UNIX for Dummies Questions & Answers
Hello everyone,
I've got a question regarding the gzip command.
I regulary use gzip to pack huge ammounts of files.
Is it ok to start 'gzip *' several times in the same directory to parallelize the packing process or can this result in problems, e.g. broken or unpacked files?
My tests... (7 Replies)
Discussion started by: Basch
7 Replies
3. Shell Programming and Scripting
hello
im new here so i want to say hi everybody :)
i have to write a script and im newbie :/ i hope that in this forum are many ppl who knows subject :)
i have hundrets folders. in each folder is a file name trace.txt. each trace.txt has a lot of tracert's results separates with "-----" it... (6 Replies)
Discussion started by: michael8484
6 Replies
4. HP-UX
Hi folks,
I am trying to run more than 8 threads in OpenMP team on my HP-UX 11i v3 system (without root access), but NO success.
Compiler: aCC A.06.26
I tried to setup: OMP_NUM_THREADS, omp_set_num_threads(), max_thread_proc=1000, nkthread=8416, set_dynamic=0
Machine has 2 processors... (1 Reply)
Discussion started by: ATveretinov
1 Replies
5. Programming
Hello to all,
Here is my situation. Some time in the mid-80's I stumbled across a small white programming book - can't remember the name but it was unique in that it started right out giving instructions on creating building blocks in code as a foundation for a complete system. The book was... (2 Replies)
Discussion started by: jozefn
2 Replies
6. Programming
Dear Linux users,
I'm a noob at openmp, gcc and c programming. I can run my own openmp code in terminal with no problem, eg. gcc -fopenmp program.c -o program.
But now I'm trying to compile and run another person's code, it contains a makefile and multiple .c and .h files. I don't know how to... (2 Replies)
Discussion started by: pigeon151
2 Replies
7. Programming
I am using a large code-base that compiled successfully before using make with a makefile and cmake. However, now that I'm trying to use openmp with it, I'm now getting the errors
undefined reference to `omp_get_thread_num'
undefined reference to `omp_get_num_threads'I don't think this... (0 Replies)
Discussion started by: larry burns
0 Replies
8. Programming
hi,
I have two basic questions, I will be really grateful if I receive any
comment from you,
I have an MPI code where I am trying to implement OpenMP directives.
The machine where I run the code has 16 cores. I run the code with
export OMP_NUM_THREADS=2
mpirun -np 4 ./exec
If I... (0 Replies)
Discussion started by: armando_2011
0 Replies
LEARN ABOUT MOJAVE
dispatch_semaphore_signal
dispatch_semaphore_create(3) BSD Library Functions Manual dispatch_semaphore_create(3)
NAME
dispatch_semaphore_create, dispatch_semaphore_signal, dispatch_semaphore_wait -- synchronized counting semaphore
SYNOPSIS
#include <dispatch/dispatch.h>
dispatch_semaphore_t
dispatch_semaphore_create(long count);
long
dispatch_semaphore_signal(dispatch_semaphore_t semaphore);
long
dispatch_semaphore_wait(dispatch_semaphore_t semaphore, dispatch_time_t timeout);
DESCRIPTION
Dispatch semaphores are used to synchronize threads.
The dispatch_semaphore_wait() function decrements the semaphore. If the resulting value is less than zero, it waits for a signal from a
thread that increments the semaphore by calling dispatch_semaphore_signal() before returning. The timeout parameter is creatable with the
dispatch_time(3) or dispatch_walltime(3) functions.
The dispatch_semaphore_signal() function increments the counting semaphore. If the previous value was less than zero, it wakes one of the
threads that are waiting in dispatch_semaphore_wait() before returning.
COMPLETION SYNCHRONIZATION
If the count parameter is equal to zero, then the semaphore is useful for synchronizing completion of work. For example:
sema = dispatch_semaphore_create(0);
dispatch_async(queue, ^{
foo();
dispatch_semaphore_signal(sema);
});
bar();
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
FINITE RESOURCE POOL
If the count parameter is greater than zero, then the semaphore is useful for managing a finite pool of resources. For example, a library
that wants to limit Unix descriptor usage:
sema = dispatch_semaphore_create(getdtablesize() / 4);
At each Unix FD allocation:
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
fd = open("/etc/services", O_RDONLY);
When each FD is closed:
close(fd);
dispatch_semaphore_signal(sema);
RETURN VALUES
The dispatch_semaphore_create() function returns NULL if no memory is available or if the count parameter is less than zero.
The dispatch_semaphore_signal() function returns non-zero when a thread is woken. Otherwise, zero is returned.
The dispatch_semaphore_wait() function returns zero upon success and non-zero after the timeout expires. If the timeout is DISPATCH_TIME_FOR-
EVER, then dispatch_semaphore_wait() waits forever and always returns zero.
MEMORY MODEL
Dispatch semaphores are retained and released via calls to dispatch_retain() and dispatch_release().
CAVEATS
Unbalanced dispatch semaphores cannot be released. For a given semaphore, calls to dispatch_semaphore_signal() and dispatch_semaphore_wait()
must be balanced before dispatch_release() is called on it.
SEE ALSO
dispatch(3), dispatch_object(3)
Darwin May 1, 2009 Darwin