You should define a global datastructure which will be accessed by the processes. When a process starts, it must update the datastructure and when it finishes it must update the datastructure. The datastructure could be a linked list which elements look like this:
Code:
struct time_table_element
{
int process_id;
struct time start_time;
struct time stop_time;
struct time_table_element *next;
};
To make difference between the processes, each proces should have an unique ID. When a process starts, it puts its ID in the process_id and the current system time in start_time. When it finishes, it current system time in stop_time.
I assume you are writing a scheduler which takes care of the round-robin algorithm you seem to use. This scheduler should also extend the time-table with a new element. This does take time, perhaps easier would be to implement a fixed time-table, like:
Code:
struct time_table_element
{
int process_id;
struct time start_time;
struct time stop_time;
};
struct time_table_element time_table [NR_OF_ELEMENTS];
This requires you to have another global variable for keeping the index. The scheduler should update the index by increasing it by one each time a new process is starting. It should also check that no more elements can be stored than the maximum.
BTW, what OS are you using?
[edit]
Since the processes are running parallel, you must make sure that no two processes can access the global data for writing at same time. To solve this you could implement a semaphore mechanism.
Note that the time-table now can look like:
00:00:02 process A start
00:00:08 process B start
00:00:10 process B stop
00:00:16 process C start
00:00:20 process A stop
00:00:26 process C stop
And you problably don't implement the scheduler,don't you? So your processes need to update the datastructure.
[/edit]