Re: A common array
From: Wes Groleau (groleau_at_freeshell.org)
Date: 12/20/03
- Next message: Ekkehard Morgenstern: "Re: [announcement] SYSAPI and SYSSVC for Windows"
- Previous message: Steve: "Re: Tasks problem"
- In reply to: Mr. J.: "Re: A common array"
- Next in thread: Ratson Janiv: "Re: A common array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 19 Dec 2003 22:23:46 -0500
Mr. J. wrote:
> I need to write a procedure that checks and prints the prime numbers
> between 1 and m.
> The procedure gets 2 parameter, m- the numbers to check 1..m and n -
> the number of tasks to perform it.
>
> each tak will check if a number is a prime number, and will update an
> array of booleans (size 1..m).
> At the end of all tasks the procedure prints the prime numbers.
Still not quite clear. Does each task update one cell,
and no other task updates that cell? IF that is the case,
then the cells do not need synchronization.
But IF one task implements a divisor, for example, setting
false every third cell, while another (for example) sets false
every fifth cell, then they could theoretically collide on
the fifteenth cell. You could say, "it's so unlikely for
that to happen at the same time that I don't need to protect
the cells." Or you could play it safe and make each cell a
protected object. (Not the whole array--why lock all tasks
out of cell X just because somebody is writing to cell Y?)
However, IF each task is only writing False into Boolean
cells initialized to True, then a collision can't hurt anything.
It ends up False no matter who gets there first.
-- Wes Groleau When all you have is a perl, everything looks like a string.
- Next message: Ekkehard Morgenstern: "Re: [announcement] SYSAPI and SYSSVC for Windows"
- Previous message: Steve: "Re: Tasks problem"
- In reply to: Mr. J.: "Re: A common array"
- Next in thread: Ratson Janiv: "Re: A common array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]