Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Barrier barrier = new Barrier(NUM_OF_THREADS + 1);

            long fileLength  = DestributedFS.getInstance().fileLength();
            long chunkLength = fileLength / NUM_OF_THREADS;

            for (int i = 0; i < NUM_OF_THREADS; i++)
            {
                long         workerThreadChunkLength = (i == NUM_OF_THREADS - 1) ? (fileLength - (NUM_OF_THREADS - 1) * chunkLength) : (chunkLength);
                WorkerThread tws = new WorkerThread(chunkLength * i, workerThreadChunkLength, barrier);

                // Create a thread to execute the task, and then
                // start the thread.
                Thread t = new Thread(tws.ThreadProc);
                t.Start(i);
            }

            barrier.SignalAndWait();
            Console.WriteLine("Threads started, waiting..");
        }
Ejemplo n.º 2
0
 public void realworker(long offset, long length)
 {
     // here we need to calcutate words and do the real work
     DestributedFS.getInstance().getData(offset);
 }