mirror of
https://github.com/deepseek-ai/3FS
synced 2025-06-26 18:16:45 +00:00
Initial commit
This commit is contained in:
64
specs/Timer/PSrc/Timer.p
Normal file
64
specs/Timer/PSrc/Timer.p
Normal file
@@ -0,0 +1,64 @@
|
||||
/*****************************************************************************************
|
||||
The timer state machine models the non-deterministic behavior of an OS timer
|
||||
******************************************************************************************/
|
||||
machine Timer
|
||||
{
|
||||
// user of the timer
|
||||
var client: machine;
|
||||
start state Init {
|
||||
entry (_client : machine){
|
||||
client = _client;
|
||||
goto WaitForTimerRequests;
|
||||
}
|
||||
}
|
||||
|
||||
state WaitForTimerRequests {
|
||||
on eStartTimer goto TimerStarted;
|
||||
ignore eCancelTimer, eDelayedTimeOut;
|
||||
}
|
||||
|
||||
state TimerStarted {
|
||||
defer eStartTimer;
|
||||
entry {
|
||||
if($)
|
||||
{
|
||||
send client, eTimeOut;
|
||||
goto WaitForTimerRequests;
|
||||
}
|
||||
else
|
||||
{
|
||||
send this, eDelayedTimeOut;
|
||||
}
|
||||
}
|
||||
on eDelayedTimeOut goto TimerStarted;
|
||||
on eCancelTimer goto WaitForTimerRequests;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************
|
||||
Events used to interact with the timer machine
|
||||
************************************************/
|
||||
event eStartTimer;
|
||||
event eCancelTimer;
|
||||
event eTimeOut;
|
||||
event eDelayedTimeOut;
|
||||
/************************************************
|
||||
Functions or API's to interact with the OS Timer
|
||||
*************************************************/
|
||||
// create timer
|
||||
fun CreateTimer(client: machine) : Timer
|
||||
{
|
||||
return new Timer(client);
|
||||
}
|
||||
|
||||
// start timer
|
||||
fun StartTimer(timer: Timer)
|
||||
{
|
||||
send timer, eStartTimer;
|
||||
}
|
||||
|
||||
// cancel timer
|
||||
fun CancelTimer(timer: Timer)
|
||||
{
|
||||
send timer, eCancelTimer;
|
||||
}
|
||||
2
specs/Timer/PSrc/TimerModules.p
Normal file
2
specs/Timer/PSrc/TimerModules.p
Normal file
@@ -0,0 +1,2 @@
|
||||
/* Create the timer module which consists of only the timer machine */
|
||||
module Timer = { Timer };
|
||||
Reference in New Issue
Block a user