Cyclic Executive (ITI8510): erinevus redaktsioonide vahel

Allikas: Lambda
Mine navigeerimisribale Mine otsikasti
12. rida: 12. rida:
# Get the internal time with [http://linux.die.net/man/2/time time()]
# Get the internal time with [http://linux.die.net/man/2/time time()]
# check for file "test.txt" in the current directory, if it exists and you can open it, display its content, close it, delete it ( [http://linux.die.net/man/3/unlink unlink()] ).
# check for file "test.txt" in the current directory, if it exists and you can open it, display its content, close it, delete it ( [http://linux.die.net/man/3/unlink unlink()] ).
# Display the time() value on screen (that you got in task #2
# Display the time() value on screen (that you got in task #2)
# Get the processor tick time with clock() function and store the amount of time since task 1 to a variable for SIGINT.
# Get the processor tick time with clock() function and store the amount of time since task 1 to a variable for SIGINT.



Redaktsioon: 11. märts 2010, kell 17:17

This lab is part of the end grading. Keep the program in directory "rtos/lab1" and name it cyclic.c for it to be found for checking-script.

Your task is to implement a small cyclic executive, which runs its tasks once in a second, otherwise idling. This will give tasks 3 priorities: normal (once a second), high (interrupts) and low (idling level).

The program should handle Ctrl+C interrupt for higher priority tasks. Implementation-wise you should use alarm() to deliver a signal every second to time the tasks. The SIGALRM should be handled with a handler which runs the 3 tasks OR sets a global variable (use sig_atomic_t as type).

The "Idle" task should do nothing initially except for checking for arrived signal and running the tasks. You may want to add some method for doing low priority tasks, but remember to keep their segments short in order to catch the interrupt flag on time.

The tasks

There should be 5 tasks, write them as functions.

  1. Get the internal processor tick time with clock()
  2. Get the internal time with time()
  3. check for file "test.txt" in the current directory, if it exists and you can open it, display its content, close it, delete it ( unlink() ).
  4. Display the time() value on screen (that you got in task #2)
  5. Get the processor tick time with clock() function and store the amount of time since task 1 to a variable for SIGINT.
  • For SIGINT interrupt, write the file "test.txt" with the time stored in task #5 .
  • (Optional) For idle task, think of something interesting to do which can be easily interrupted if sigalrm arrives.

Note that you can probably adapt some of the code from the intterrupt practice assignment.