Virtual Clock


Introduction

In this lab you will implement a software Real-Time Clock, i.e., a Virtual Clock (VC). One possible implementation of a VC is to tie into a timer interrupt and accordingly update time variables such as hour, minute, etc. The accuracy of a VC using such an implementation is a function of the accuracy of the underlying timer. As an example, using an 8052's 16 bit timer in auto reload mode with an initial seed of 3072, one can generate 3600 interrupts every second with a .72 second of drift or lag per day.

In your implementation, you will be given a template program that has the interrupt code (generated from a concurrently running thread). You are to write code for the interrupt handler (UpdateTime), SetTime and GetTime routines. In addition, you are to provide synchronization between the SetTime, GetTime and UpdateTime processes. You can assume that SetTime and GetTime will be called by a sequential program, i.e., a single instance of GetTime or (exclusive) SetTime will be invoked at any given time. UpdateTime, however, can be asynchronoulsy invoked at any time.

Start Here:

Demo Output

Write a test program that uses your VC and provides an interactive Set and Get time interface to your TA.