I'm struggling with an algorithm i've attempted in C.
The idea of the algorithm is to take a given range of numbers, say 1..100, and divide it into n equal chunks, with the final chunk absorbing any remainders. This a really common algorithm, but i don't know it's name to look up a reference implentation.
Here's my attempt thus far:
1. Identify a range the process should work on
2. Partition that range into equal chunks, so that the chunks can be allocated to worker threads
3. Fire each chunk out to a thread for processing
Where per_thread_bounds is defined as:
This works fine for n (or total_thr) < 11, for the given range 1..100. However when i choose 11 worker threads over the range 1..100, the numbers are divided up as per 10 worker threads, leaving a spare worker thread (#11) which is allocated a range 101..100!
Not what i intended :-)
So i guess it's todo with my rounding, and generally poor algorithm for partitioning a range. How do i improve it?
You could also spawn off a number of threads and have each one pull the next item off the entire range. I.E. have a "next range item" variable and a mutex that protects it.
Each thread (in a loop until all values in the range are processed) locks the mutex, take the current value, increments it, unlock the mutex, and computes on the current value. This does create a hot spot at the mutex, but if the computation takes significantly long then I don't see that being a big deal.
I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows,
/boot - Linux Partition & another is
LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc).
Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
I would like to know different between soft partition concept and hard partition concept on solaris.
Here is little explanation between soft partition concept and hard partition concept on solaris.
1TB total space available in storage in all mapped to the OS to... (2 Replies)
while formatting hard disk i am getting following error.
Partition 1 ends at 266338338
It must be between 34 and 143374704.
label error: EFI Labels do not support overlapping partitions
Partition 8 overlaps partition 1.
Warning: error writing EFI.
I have formatted the... (2 Replies)
I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated.
Pattern1... (2 Replies)
I've created a partition with GNU Parted, how do I mount the partition?
The manual information at http://www.gnu.org/software/parted/manual/parted.html is good, but I am sure about how I mount the partition afterwards.
--Todd (1 Reply)