Application of partial evaluation to hard real-time programming

In order to ensure the timely execution of hard real-time applications, operating systems need to take the timing constraints, the resource requirements, and the synchronization constraints of applications into account while scheduling. These factors are affected by the design of high-level language constructs. Many real-time programming languages restrict the use of high-level programming constructs since their use make it difficult to determine the resource requirements and timing properties of programs. This forces the development of low-level programs that are difficult to develop, debug and maintain. These programs are neither portable nor reusable. In this dissertation, we propose the technique of partial evaluation as a solution to this problem. Given a real-time program employing high level language constructs, this technique uses the information about the execution environment to create a specialized program tailored for that particular environment. Specialized programs can be better analyzed to accurately estimate the resource requirements. This technique allows the programmer to use language constructs that are otherwise forbidden, helps obtain more accurate estimates, and helps identify many errors, such as non-termination, at compile-time. We provide a formal definition of the partial evaluator and prove its correctness. We also present high level timing constructs for specifying application level timing constraints. With these constructs, the programmers do not have to resort to low-level timing mechanisms. The partial evaluator extracts the timing constraints from the constructs and provides them to the scheduler for scheduling. For concurrent programs, unsafe sharing of data and unpredictable interleavings make the estimation of execution time difficult. In this dissertation, we use partial evaluation to detect and forbid any unsafe sharing or non-deterministic interleavings that may affect the execution time. Partial evaluation also produces specialized concurrent programs for which the estimation of execution time is possible. Further, we propose a synchronization mechanism based on pre-scheduling. Our synchronization primitives are designed so that they can be taken into account by a pre-scheduler to produce, prior to run-time, the interleavings that meet the synchronization constraints. This scheme does not have run-time synchronization overhead and can be used to determine the exact timing properties of synchronizing processes.