views:

62

answers:

2

I am trying to create +5 threads synchronously so there shouldn't be any concurrency error.
Code:

System.Threading.Thread t = new System.Threading.Thread(proc);
t.Start();//==t.BlueScreen();
t.Join();

Is darkness a feature ?
I am doing something wrong?

OS:Microsoft windows vista(unfortunately) x64
Language:C# 3.0|4.0
.Net version:3.5|4

edit:

Personel[] spersonel;

proc:

void proc()
{
    spersonel = Personel.GetRows(GetThreadSafeDataConnection());
}

Personel:

   internal static Personel[] GetRows(System.Data.SqlClient.SqlConnection Connection)
        {
            int i = 0;
            int c = SomeOtherGODClass.Val_int(SomeGODClass.ExecuteScalar("Select Count(*) from Personel", Connection).ToString());
            Personel[] Rs = new Personel[c];
            System.Data.SqlClient.SqlDataReader sdr = SomeGODClass.ExecuteReader("Select * from Personel", Connection);
            while (sdr.Read()) Rs[i++] = new Personel(sdr);
            sdr.Close();
            if (Rs.Length > 1) mergeSort(ref Rs);
            return Rs;
        }
+3  A: 

The code snippet you pasted looks fine, but doesn't really tell us much. It would be helpful to paste contents of proc, and provide us a larger scope of what your program is doing.

It might also be helpful to paste as much of the contents of the BSoD as possible, including why it occurred (access violation, etc). Although not directly helpful, it would provide some clues.

Justin Ethier
the proc reads data with a SqlDataReader and uses a SqlConnection that is opened before.
Behrooz
Under no circumstances should the OS throw up a BSoD. That said, are you sure that it is properly synchronized across threads? Does the code BSoD when you only run it under a single thread?
Justin Ethier
it doesnt BSod when working with 1 thread. and the error code is 0xc0000007
Behrooz
Can you post the code for `proc`?
Justin Ethier
+1  A: 

Your error code is not a typical BSOD code. It is STATUS_PAGEFILE_QUOTA, "The pagefile quota for the process has been exhausted."

Getting this on a 64-bit version of Windows is possible. 64-bit programs cannot run out of memory, they've got 16 terabytes of virtual memory. They run out of mappable memory pages first. The operating system sets an upper limit to how much of the paging file size a program can hog. You exceeded it. If it is really a BSOD then it probably ran out of kernel memory pool space, each thread you create needs about 24 KB of memory for the kernel stack.

I have to guess that your program is creating way too many threads. Keep any eye on the Threads column in Taskmgr.exe, Processes tab. The Performance tab shows what's happening to the kernel memory pool.

Hans Passant