Differences
This shows you the differences between two versions of the page.
en:software:qview:qview_6:qcl_library:sy10initializecriticalsection [2017/04/04 17:05] – created qem103 | en:software:qview:qview_6:qcl_library:sy10initializecriticalsection [2019/08/29 17:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SY10InitializeCriticalSection ====== | ||
+ | |||
+ | **SY = **//System function// | ||
+ | |||
+ | The SY10InitializeCriticalSection function __Initializes a critical section pooling information__. | ||
+ | |||
+ | ===== IMPLEMENTATION ===== | ||
+ | |||
+ | **SY10InitializeCriticalSection(pool)** | ||
+ | |||
+ | Parameters: | ||
+ | |||
+ | ^IN/ | ||
+ | | IN | ARRGBL | ||
+ | |||
+ | Description: | ||
+ | |||
+ | Every critical section bases its inner workings on a proprietary data structure called //pool// informations.\\ | ||
+ | Every critical section will have its own //pool// that must be initialized before it can be used.\\ | ||
+ | The //pool// consists of an array of bytes where the number of items depends on the number of task unit that will use more two-byte fixed header. | ||
+ | |||
+ | |||
+ | Inglese | ||
+ | Italiano | ||
+ | If for example a given critical section is used in only two drives task you create an application pool of 4 byte making sure that a unit must use the ID 1 while the second the ID 2. | ||
+ | |||
+ | The ID are progressive starting from 1 and identify the location of the information in the pool, then pass an ID with index not available in the pool means invalidating the call and how it works. | ||
+ | |||
+ | **NB**: To avoid problems it is advisable to size the pool information with sufficient size to address all drives task. | ||
+ | |||
+ | === Example === | ||
+ | |||
+ | In the following example initializes an information pool used then to a critical section. | ||
+ | |||
+ | |||
+ | \\ | ||
+ | **configuration unit:** | ||
+ | <code QCL> | ||
+ | ; critical section consts | ||
+ | CONST | ||
+ | CS_POOL_HEADER 2 ; | ||
+ | CS_POOL_SIZE 10 ; | ||
+ | |||
+ | ARRGBL | ||
+ | LockPool B CS_POOL_HEADER + CS_POOL_SIZE | ||
+ | </ | ||
+ | |||
+ | |||
+ | \\ | ||
+ | **Unit initialization: | ||
+ | <code QCL> | ||
+ | ;=== | ||
+ | ; | ||
+ | ; | ||
+ | GLOBAL | ||
+ | Initialized F OUT | ||
+ | |||
+ | ; main entry point | ||
+ | BEGIN | ||
+ | CALL TASK_INIT | ||
+ | WHILE TRUE | ||
+ | CALL TASK_EXECUTE | ||
+ | WAIT A_LOOP | ||
+ | ENDWHILE | ||
+ | END | ||
+ | |||
+ | ;=== | ||
+ | ; Task initialization | ||
+ | ; | ||
+ | SUB TASK_INIT | ||
+ | SY10InitializeCriticalSection(LockPool) | ||
+ | Initialized = TRUE | ||
+ | ENDSUB | ||
+ | |||
+ | ;=== | ||
+ | ; Task execution | ||
+ | ; | ||
+ | SUB TASK_EXECUTE | ||
+ | SUSPEND | ||
+ | ENDSUB | ||
+ | </ | ||
+ | |||
+ | === Note === | ||
+ | |||
+ | *The function must be performed only once during application initialization. | ||
+ | *The [[software: | ||