• 沒有找到結果。

An algorithm for coalescing operations with precedence constraints in real-time systems

N/A
N/A
Protected

Academic year: 2021

Share "An algorithm for coalescing operations with precedence constraints in real-time systems"

Copied!
5
0
0

加載中.... (立即查看全文)

全文

(1)

Information Processing Letters 46 (1993) 129-133 Elsevier

llJune1993

An algorithm for coalescing operations with

precedence

constraints in real-time systems

Lung-Tien

Liu

Telecommunication Laboratories, P. 0. Box 71, Chung-Li, Taiwan, ROC

Gen-Huey

Chen

Department of Computer Science and Information Engineering, National Taiwan University, Taipei, Taiwan, ROC

Kwei-Jay Lin

Department of Computer Science, University of Illinois, Urbana, IL, USA Communicated by D. Gries

Received 14 November 1991

Revised 20 July 1992 and 26 February 1993

Keywords: Algorithms; dynamic programming; maximum weighted compatible matching; real-time systems

1. Introduction

Real-time

computations

have deadline con-

straints. In addition to providing a result with a

correct value, a real-time computation must pro-

duce the result before the deadline. A real-time

system usually has many jobs sharing system re-

sources, such as CPU and I/O devices. The sys-

tem must provide a feasible schedule for all jobs

so that they can finish executions before their

deadlines. In many applications

[

1,3], real-time

systems are modeled as object-oriented

systems.

In an object-oriented

system, each object has a

set of well-defined operations. Each object also

has local variables, which may be accessed only

Correspondence to: Professor G.-H. Chen, Department of Computer Science and Information Engineering, National Taiwan University, Taipei, Taiwan, ROC.

by the operations defined in the interface of the

object. The object decides if and when to process

the requests from other objects.

In real-time systems, an object usually makes

scheduling decisions in order to maximize the

system performance.

There are many ways to

make scheduling decisions.

Operation coalescence

is one of them [2]. The idea is that some objects

may be able to handle several distinct requests at

the same time. For example, suppose a stack

object is implemented

in a system and suppose

the public, or primitive, operations

defined for

the stack object are:

push, pop, new

and

top.

We

may provide a coalesced operation

double-push,

which takes two elements and pushes both of

them onto the stack at the same time. Whenever

two consecutive

push

operations

are found in

front of the request queue for the stack object,

the object scheduler can invoke the coalesced

(2)

Volume 46, Number 3 INFORMATION PROCESSING LETTERS 11 June 1993

operation double-push instead. For many dis- tributed systems using the client-server model, operation coalescence can be easily adopted.

By coalescing several requests into one single request, the workload of the object may be re- duced. Moreover, the response time for a job waiting for the result from the object may be shortened if its request is coalesced with an ear- lier request from another job. It is true that other requests in the middle may be delayed if a later request is coalesced with an earlier request. It is therefore the responsibility of the object or the system scheduler to decide if a coalescence should be performed. This is similar to the proposal of using non-conventional protocols to handle real- time transactions [4]. By executing urgent transac- tions first [5] and delaying non-urgent requests, a real-time system can provide better performance by meeting more deadlines.

In most applications, coalesced operations must be defined by the programmer, due to the semantic issues involved. On the other hand, whether a coalescence should be performed is usually decided by the object (or system) sched- uler. In the scheduler, the reward (usually the amount of computation time saved) for each coa- lesced operation must be pre-analyzed and recorded in a reward table before execution. When a sequence of requests arrive, the sched- uler consults the reward table and determines which requests to coalesce in order to maximize the total reward.

In a real-time system, the request patterns of many jobs are known in advance, especially when jobs are periodic. For example, service requests from a radar monitor are periodic and well-de- fined. Given K periodic jobs and the reward table, we can determine which requests to coa- lesce to produce the maximum total reward. In other words, we can find the coalescence sched- ule that saves the most time. If some requests are not predefined, we can still perform the analysis at run-time if the complexity of scheduling coa- lesced operations is not high. Unfortunately, find- ing an optimal schedule in the general case is NP-hard 111. To simplify the problem, we assume that only two primitive operations can be coa- lesced at a time.

In this paper, we consider the model in which each periodic job J, has II sequential operations {Jji, JiZ,..., Ji,} and execution of each job must satisfy ‘the precedence constraint, i.e., each oper- ation Ji,j cannot be executed until operation Ji,j_ I has completed, 1 <j Q n. For any two operations, there is a reward value. If the two operations cannot be coalesced, the reward value is zero. Our objective is to find a feasible coalescence schedule that produces the maximum total re- ward.

For the case of two periodic jobs, Chen et al. [ll have developed an 0(n6) time algorithm for the problem. Using dynamic programming, we improve their work by presenting an 0(n2) time algorithm. Moreover, the algorithm can be ex- tended to handle any k periodic jobs with time complexity O(k2nk).

2. An O(n21 time algorithm for scheduling two

periodic jobs

We assume that there are two periodic jobs in the real-time system, and each job .( has n sequential operations (Ji,i, Ji,2,. . . , Ji,,), i = 1, 2. To describe the problem formally, we represent the system as an undirected graph. Each vertex ui,j denotes an operation Ji,j. There are edges between ui,j and u~,~+ i, i = 1, 2, j = 1,. . . , n - 1, and between vlp and vZq, p= I,..., n, q = 1 ,..-, n. Each edge is associated with a weight representing the reward value. Thus, maximizing the total reward is equivalent to finding a maxi- mum weighted compatible matching 111 in the graph.

Any two edges (u~,~, u~,~), (u,,,, u2,J in a

weighted compatible matching satisfy either r <p and s < q or r > p and s > q. In other words, the maximum weighted compatible matching problem is to find a subset of edges that do not cross each other and whose total weight is maximized. This subset of edges is called the maximum weighted compatible matching set.

As an example, Fig. 1 shows a real-time object with four primitive operations op,, op,, op,, and op4. There are two periodic jobs and each has four operations. Job J, consists of op,, op,, op,,

(3)

Volume 46, Number 3 INFORMATION PROCESSING LE’ITERS 1lJune 1993

Fig. 1. An example of scheduling operations with precedence constraints.

Job J2 consists of op,, op,, op,, and op2 (J2,,, J2,2, J2,3 and J2,4, respectively). The reward values are given in Table 1. The maximum weighted compatible matching set is indicated as solid lines in Fig. 1. The maximum total reward is 16 and the scheduling sequence is J2,1, J,,, +

J,,,, JI,, +

J2,,7 J1.2 + J1,39 JI,,.

Let Ri,j denote the maximum total reward for matching operations in (J,,,, . . . , J,,i) and (J,,,, . . . , J2,j}, ri,j the weight of edge (~i,~, uZj), 1 G i G n, i 6 j G n, and ck,, the weight of edge &,l- I, vk /), k = 1, 2, 1 < 1 =G n. Clearly, consider- ing operations J,,i and J2,j, we have the following equations:

Ri,j = max{Ri-i,j, Ri,j-i, ci,i +Ri-Z,j, c2j+Rij-2, rij+Ri_ij-i} for2<i=gn,2gj<n,

R1,~ = mm{RO,j? Rl,j-lT ‘2.j + Rl,j-2, ‘1.j + RO,j- 1)

for 2<j<n,

Ri,l = max{%,,,, Ri,o, ~1,~ +Ri-z,l, ‘i,l + Ri- I,01

for 2,<i<n, RO,j = max{RCl,j-17 ‘Z,j + R0,j-2j for 2<j,<n, (1) (2) (3) (4) Table 1

An example of the reward table

OPl OP2 W3 ou4

OPl 2 7 5 0

OP2 7 2 0 4

OP3 5 0 2 1

fJP4 0 4 1 2

Ri,o =

max(Ri-l,oT

Cl,i +

Ri-2,0}

for 2<iGn, (5)

R,,, = R,,, = R,,, = 0,

R,,, = rl,l if r,,, > 0, and R, i = 0 otherwise. (6) In (l), the first (second) term in the right-hand side represents the case that operation J,,i (J2,j) is not coalesced with any other operation. The third (fourth) term represents the case that oper- ation J, i (J, j) is coalesced with its immediate predecessor. The fifth term represents the case that J,,i is coalesced with J2,j. No other cases are possible, because edges in the maximum weighted compatible matching set are not allowed to cross each other due to precedence constraints. The other equations are derived similarly.

With initial values given by (61, the following algorithm takes O(n’) time to compute the value R, n n, which is the maximum total reward.

/ * Initialization */

R,,, := 0; R,,, := 0; R,,, := 0;

if rll

for I :_>,o;;en”~i,I := r1,1 e’se Rl,l := 0; Ri,o := maxIR,_ 1,0, Cl,i + Ri-4;

for j := 2 to n do

R,,j := m4R,,j-,, C2.j + R,j-,l;

for i := 2 to n do

Ri,l := m4RRi-l,l, Ri,o, Cl,i +Ri-2,1, ri 1 + Ri-l,J; for j := 2 to n 60 R,,j := maxIR,,j, R,,j-l, C2,j + Rl,j-2, rl,j + R,,j- 1); / * Compute R, n */ for i := 2 to n do’ for j := 2 to n do

Ri,j := mti(Ri_,,j, Ri,j_,, Cl,i + Ri_2,j,

C2j+R~j-2, rij+Ri_,,j_,).

3. Extension to k periodic jobs

We now extend our result to k 2 3 periodic jobs. We assume that each job J,, 1 ( i 6 k, has n

(4)

Volume 46, Number 3 INFORMATION PROCESSING LETTERS 11 June 1993

sequential operations IJ,,r, Ji,z, . . . , JJ. Let R r~ll,r~21,, , tfkl denote the maximum total reward for matching operations in {Jr,,, . . . , Jl,tIIJ, 1.f~ 1, . . . , J2,f[21), . . . ,(J~,I~ . . . , Jk,t[kl), ri,j,p,q the weight of edge (u~,~, up J, 1 G i G k, 1 <j < n, 1 <

p G k, 1 G q <n, i fp, and c,,, the weight of edge (v,,,_,, v,,,), 1 G u < k, 1 < u <n.

Depending on whether operations in S = {J Lqll J2,,[2]7 . . . 7 &,,,kJ are coalesced with some other operations, there are three possible cases.

Case 1: Some operation in S is not coalesced with any other operation. We have

M,=R r[ll,t[21,. , Qkl =

m~~R,~l]-1,,[2]....,r[k]~ R r[l],r[2]-l,...,r[k]’ . ..) R t[l],r[2],...,t[k]- 1 1.

Case 2: Some operation in S is coalesced with its immediate predecessor. We have

M,=R t[l],r[2]. , r[k]

- max{cl,,[,] +Rt[l]-2,r[2],...,r[k],

C2J[2] + R r[l],r[2]-2 ,..., t[k],. .,

Ck,r[k] + R r[l],r[2],...,t[k]-2 1.

Case 3: Two operations in S are coalesced. If .I l,rtll is coalesced with J2,tt21, the maximum total

reward is equal to rl,f[ll,2,r[2] + K[l]- 1,r[2]- 1,. , r[k]. Thus, we have M,=R r[ll,r[2l,...,~[kl = max{rl,t[l],2,t[2] + R~~l]-l,t[21-l,...,f[kl’ r1,t[1],3,1[3] + Rt[l]-l,r[2],1[3]-1,...,r[k], . . . rl,t[l],k,r[k] + Rrrl]-l,r[2],...,t[k]-l, r2,t[2],3,t[3] + R t[l],r[2]- l,r[3]- 1, .,t[k]’ rZ,t[2],4,r(4] + R r[l].r[2]- 1,r[3],r[4]- l,..., t[k], . . . 3 r2,t[2],k,r[k] + R r[1],r[2]- 1,r[3] ,..., qkl- 1’ . . . ? rk-l,r[k-l],k.t[k] +R t[l],r[2],...,r[k-I]-1,r[kl-1 1.

Due to precedence constraints, no other cases are possible. Therefore, Rr~ll,r~21,~ _, , trkl = max{M,, M,, M3}. For example, given operations {Jr,,, . . . , JJ, i&,1, . . . , J2,4I, and (J3.1, . . . , J3,4),

Ml = max( R3,,,, y R4,3,4 ) R4,4,3} 7

M2 = max{cl,4 + R2,4,4f c2,4 + R4,2,49 c3,4 + R4,4,2} )

and

M3 = maxh,4,2,4 + R3,3,47 rl,4,3,4 + R3,4,3,

r2,4,3,4 + R4,3,31 .

The maximum total reward is R 4,4,4 = max{ Ml 7 M2 7 M3I = m={R3,4,4 7 R4,3,4 f R4.4.3) c1,4 + R2,4,4 3 c2,4 + R4,2,4) c3,4 + R4,4,2 7 rl,4,2,4 + R3.3,4) r1,4,3,4 + R3,,,,) r2,4,3,4 + R4,3,3} .

It is not difficult to show that the time complexity of computing the maximum total reward R,,.,, is 0(k2nk).

4. Discussion and conclusion

Using dynamic programming, we have devel- oped an 0(n2) time algorithm for the proposed problem. The same technique can be easily ap- plied to the case of coalescing three or more operations. It is not difficult to see that O(n3) time is sufficient for the case of coalescing three operations.

Although we made a significant improvement over Chen et al.‘s work, we have not determined what the lower bound for the problem is.

References

[l] T.E. Bihari and P. Gopinath, Object-oriented real-time systems: Concept and examples, IEEE Comput. 25 (12) (1992) 25-32.

[2] M.I. Chen, J.Y. Chung and K.J. Lin, Scheduling algorithm for coalesced operations in real-time systems, in: Proc. COMPSAC 89, Orlando, FL (1989) 143-150.

(5)

Volume 46. Number 3 INFORMATION PROCESSING LETTERS 11June 1993

[3] K.B. Kenny and K.J. Lin, Structuring large real-time sys- terns with performance polymorphism, in: Proc. IEEE Real-Time Systems Symp. (1990) 238-246.

[4] T.W. Kuo and A.K. Mok, Application semantics and con- currency control of real-time data-intensive applications,

in: Proc. IEEE Real-Time Systems Symp., Phoenix, AZ (1992) 35-45.

[5] C.L. Liu and J.W. Layland, Scheduling algorithm for mul- tiprogramming in a hard real-time environment, J. ACM 20 (1) (1973) 46-61.

數據

Fig.  1.  An  example  of  scheduling  operations  with  precedence  constraints.

參考文獻

相關文件

– Each time a file is opened, the content of the directory entry of the file is moved into the table.. • File Handle (file descriptor, file control block): an index into the table

The performance guarantees of real-time garbage collectors and the free-page replenishment mechanism are based on a constant α, i.e., a lower-bound on the number of free pages that

The schedulability of periodic real-time tasks using the Rate Monotonic (RM) fixed priority scheduling algorithm can be checked by summing the utilization factors of all tasks

6 《中論·觀因緣品》,《佛藏要籍選刊》第 9 冊,上海古籍出版社 1994 年版,第 1

In Case 1, we first deflate the zero eigenvalues to infinity and then apply the JD method to the deflated system to locate a small group of positive eigenvalues (15-20

In particular, we present a linear-time algorithm for the k-tuple total domination problem for graphs in which each block is a clique, a cycle or a complete bipartite graph,

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

If the skyrmion number changes at some point of time.... there must be a singular point