當增加某項資源於一個activity process 上時,可利用類似Algorithm 5 及 Algorithm 6 進行檢查,差別只是在比較資源相依性時僅考慮特定的一項資源
當刪除一個 activity process 或刪除一個 activity process 當中的一項資源 時,利用前述的兩個互動式資源衝突檢驗演算法,也可在真正執行刪除動作前,
偵測已存在的資源衝突,做為告知使用者哪些會消除的資源衝突資訊,然後執 行刪除動作。思考上述兩項互動式檢驗分析的方法,若能將以各process 使用資 源的情況儲存於SPLIT process 上,則利用這些背景知識將有助於快速分析編輯 操作,避免在分支流上逐點比對的工作。下一節將介紹如何利用這些記錄當作 背景資訊加速資源衝突檢驗分析。
接下來討論關於Algorithm 6 的時間複雜度,所有的 process 至多拜訪一 次,因此在worst case 的情況下,即拜訪工作流程規格中所有的 process,時間 複雜度為O(n)。
3.4 利用分支路徑的資源串列達成遞增式分析
經由前述互動式的分析方法,雖然縮小資源檢驗所需考量的範圍,但尚未 能有效的提升檢驗效率。本節介紹如何搭配分支路徑的資源串列記錄的方式達 成遞增式資源衝突的分析。
首先針對工作流程規格中的 Control Block、分支路徑(SPLIT_PATH),與分 支路徑上的資源串列(resource list)做以下的定義:
由以上的定義,接下來探討當process n 上的一項資源做增刪操作,欲檢驗 是否有資源一致性的改變,可利用類似Algorithm 6 CPV 中對 n 做回溯式的搜 尋,當找到一個 AND-SPLIT,首先更新此 AND-SPLIT 對於 n 所處分支路徑 (SPLIT_PATH)上的資源串列記錄,然後其他的分支路徑存於一個集合當中,最 後比較此集合中的各個分支路徑(SPLIT_PATH)對應的資源串列記錄,如此避免 掉在工作流程的控制流結構當中進行traverse。假設編輯操作為 process n 中某 項資源 r 的新增,則以下圖的流程來說明稍後將介紹的遞增式演算法。其中第 一個區塊當中(1)的部分為搜集與 n 處在 AND-SPLIT 平行路徑上的分支路徑 (SPLIT_PATH),此條件可視為造成資源衝突的第二條件,接著更新資源串列記
Definition 7 (Resource List on the SPLIT_PATH)
RLSPi is a resource list on the SPLIT_PATH SPi , where
∀ nj∈SPi, RLSPi = U Rj
∀ r , r is a resource, RLspi.ProcessRef(r) ={n |k nk∈SPi, r ∈Rk} Definition 6 (Control Block)
B = <n , s n > is a Control Block e
B.start = n , s ns∈N, B.end = n , e ne∈N
n .TYPE = AND_SPLIT if and only if s n .TYPE = AND-JOIN e or n .TYPE = XOR_SPLIT if and only if s n .TYPE = XOR-JOIN e
∀path ps = <n ,s n ,1 n ,…, 2 n ,k n >, e n , s n , e ni∈N, i=1,2,...,k for each ps, we call such path a SPLIT_PATH
∀ n , i n .TYPE=AND_SPLIT there exists an corresponding process i n such j that i< j≤k n .TYPE=AND_JOIN j
∀ n , i n .TYPE=XOR_SPLIT there exists an corresponding process i n such j that i< j≤k n .TYPE=XOR_JOIN j
突的第一個條件,以回傳出正確的資源衝突集合。
將上述流程圖中 (1) 的部分獨立為副函式 CSP (Collect SPLIT_PATHs),並 回傳一個 SPLIT_PATH 的集合,而 (2) 的部分則獨立為副函式 CRD (Check Resource Dependency),回傳的是一個資源衝突集合 (CONFLICT SET),其中每 個元素描述哪項資源對應到哪兩個process 的一項資源衝突。其詳細內容撰寫如 下:
SPLIT_PATH SET CSP(workflow specification ws, process n, resource r ) 1 {
2 SPLIT_PATH SET P=φ; // to store parallel AND-SPLIT paths of n 3 flow queue Q=φ; // in-flows of n for back tracking
4
5 insert all in-flows of n in ws into Q;
6 // Finding all parallel SPLIT_PATHs with n 7 while Q≠φ
8 {
9 remove the first flow f from Q;
10 n’ = source process of f;
(1) Collect p, a set of all
the SPLIT_PATHs parallel with process n by backtracking from n to start node of ws, and update the resource list on the SPLIT_PATH SP where n ∈ SP
(2) Check Resource Dependency and collect the resource conflicts set by referencing RLSPi.ProcessRef(r) records,
∀SPi ∈ p
11 if (n’.TYPE=AND-SPLIT) then
12 {
13 ∃ SPk such that n’, n ∈ SPk;
14 RLSPk.ProcessRef(r )=RLSPk.ProcessRef(r ) + n;//update records 15 for each out-flow f’≠ f of n’
CONLICT SET CRD(SPLIT_PATH SET P, process n, resource r ) 1{
2 CONFLICT SET RC=φ; // record resource conflicts set 3 // Checking resource dependency
4 for each SPLIT_PATH SPi ∈ P
綜合以上兩個副函式,則可將遞增式的演算法 IAC (Incremental Analysis for Conflicts) 描述如下:
void IAC(workflow specification ws, process n, resource r ) 1 {
2 SPLIT_PATH SET P=φ; // to store parallel AND-SPLIT paths of n 3 CONFLICT SET RC=φ; // resource conflicts set
4
5 // Finding all parallel SPLIT_PATHs with n 6 P = CSP(ws, n, r);
7 // Detecting resource dependency 8 RC = CRD(P, n, r);
9
10 // showing information to users
11 for each resource conflict (r, n, nj) in RC
12 printf(“There is a resource conflict ”, (r, n, nj));
13}