I am using Silk 2010 and am having some fun grappling with the "global" scope of FileCSVLoadGlobalFile. I have found that multiple VUs actually seem to see the same rows in the file unless I wrap the file access in a mutex. I have this now, and it works well:
Code:
transaction TInit
begin
// Load CSV and set the delimiter to ","
hMutex := CreateMutex("SerializeIDList");
FileCSVLoadGlobal(hUIDFile, UIDFilePath, ",");
FileGetRow(hUIDFile, POST_Start_User_Row);
Then:
Code:
// Advance to the next row of the file and
// get the UID and User Name from the current row
// The application accepts nicknames only up to
// 20 chars. When re read them here, we may truncate to 20.
// The names in the ID-list should be 8+" "+8 at most -- 19
// characters.
//
WaitForSingleObject(hMutex, INFINITE);
nRow := FileGetNextRow(hUIDFile);
ThisUserID := FileGetCol(hUIDFile, 2, 20);
ThisUserName := FileGetCol(hUIDFile, 3, 20); // may truncate
// restrict to this range
//
if (nRow >= POST_End_User_Row) then
FileGetRow(hUIDFile, POST_Start_User_Row);
end;
ReleaseMutex(hMutex);
What I want to do is to have different scripts load the same file, but operate over different ranges of lines in the file. Script A will use rows 1001-5000, B 5001-10000, something like that. A and B multiple VUs should run A and B.
So to get this right, I think I need to understand what is the scope that FileCSVLoadGlobal() is global to? Is it the whole controller, regardless of what script? Only global to instances of a given BDH? All instances of the specific file path?
Unlike with the CreateMutex() I don't get to make up my own scope, and the scope rules don't seem to be clearly spelled out.
If anyone can clarify or suggest how to handle this, I would appreciate. Thanks.
--------------------
Gardner
Edited by gardner (12/16/11 03:03 PM)