180 likes | 340 Views
Program Testing. Testing can never prove that a program is correct Try to find errors in your code General tests No run-time error Deal successfully with different input parameters Not acceptable parameters values Critical parameters values (min, max)
E N D
Program Testing • Testing can never prove that a program is correct • Try to find errors in your code • General tests • No run-time error • Deal successfully with different input parameters • Not acceptable parameters values • Critical parameters values (min, max) • Produce acceptable outputs (as required) • Correctness • Produce expected results • Example: number of process switch
Program Testing • Simulation parameters • Memory size (KB) • Maximum uninterrupted cpu time for a process (ms) • Average I/O operation time (ms) • Simulation length (ms) • Average time between process arrivals (ms) • Process properties • Memory (100 KB – 25% total memory) • Runtime or CPU time (100ms – 10000ms) • Average time between I/O operations (1% – 25% runtime)
Program Testing How do you select the simulation parameters values to express different testing scenarios? Number of processes in CPU queue Arrival time of a next process is greater than the life-time of the previous process No process in CPU queue No process switch when RR time expired Number of processes in I/O queue Duration of an I/O operation is very long (e.g. 10000ms)
500 ms 500 ms 500 ms 500 ms P1 P2 P1 P2 P1 P2 CPU Example of Process Switching Test • Example • 2 processes (P1 and P2) in CPU queue • Run-time of each process is 1000 ms • There is no I/O operation • Round Robin time slice is 500 ms • How many process switches happen? 3
1000 ms P1 1000 ms P2 P1 P2 CPU Example of Process Switching Test • Assume Round Robin time slice is now 1000 ms • How many process switches happen? • None • What happens if RR time is 1 ms? • 1999
Example of Process Switching Test • Assume • 2 processes (P1 and P2) in CPU queue • Run-time of each process is 1000 ms • There is one I/O operations required for each process • Duration of each I/O operation is 700 ms • Round Robin time slice is 1000 ms • How many process switches happen?
500 ms 500 ms P1 Example of Process Switching Test • How many processswitches happen? • None. I/O 500 ms 500 ms P2 I/O P1 P2 P1 P2 CPU I/O P1: 700ms P2: 700ms I/O queue length? 1
Example of Process Switching Test • Assume • 2 processes (P1 and P2) in CPU queue • Run-time of each process is 1000 ms • There is one I/O operations required for each process • Duration of each I/O operation is 700 ms • Round Robin time slice is 300 ms • How many process switches happen?
Example of Process Switching Test 400 ms 600 ms P1 • How many processswitches happen? • Two. I/O 800 ms 200 ms P2 I/O CPU Idle P2 P1 P2 P1 P2 CPU 300ms 300ms 300ms 200ms 600ms 200ms P1 100ms I/O P1: 700ms P2: 700ms
Example of Process Switching Test • When does process switch happen? • Round Robin time is expired • There are processes waiting in CPU queue • When does process switching not happen? • A process is complete • An I/O operation • How does the RR time slice affect number of process switches? • 10ms, 100ms • Critical values e.g. 1ms, 10000ms • Other important values e.g. 5000ms, 20000ms
Example of Process Switching Test • How do I/O operations affect the number of process switches? • No I/O operation? • Average duration of an I/O operation is zero • Handle separately • Short duration I/O e.g. 10ms, 100ms • Long I/O e.g. 1000ms, 10000ms, 25000ms • How do the number of processes in the CPU queue affect the number of process switches? • Zero process • Arrival time of a next process is greater than the life-time of the previous process
Example of Process Switching Test • Combination of parameters values • Example • Memory size (KB): 1000 • Maximum uninterrupted cpu time for a process (ms): 1 • Average I/O operation time (ms): 1 • Simulation length (ms): 20000 • Average time between process arrivals (ms): 1 • Expected results • Number of process switch is • 19999 (if last process switch at 20000th time is counted) • 19998 (if last process switch at 20000th time is not counted)
Example of Process Switching Test • Example • Memory size (KB): 1000 • Maximum uninterrupted cpu time for a process (ms): 10000 • Average I/O operation time (ms): 1 • Simulation length (ms): 20000 • Average time between process arrivals (ms): 1 • Expected results • Number of process switch? 0
Example • Parameters values • Memory size (KB): 1000 • Maximum uninterrupted cpu time for a process (ms): 100 • Average I/O operation time (ms): 1 • Simulation length (ms): 20000 • Average time between process arrivals (ms): 100 • Output results • Number of completed processes: 0 • Number of created processes: 205 • Number of (forced) process switches: 178 • Number of processed I/O operations: 10
Example • Assume that there is no I/O operation • Maximum number of process switch: 199 (= 20000/100 -1) • From test output • Number of process switches: 178 • The total number of I/O operations and the completed processes must be: 21 (= 199 – 178) • But • Number of completed processes: 0 • Number of processed I/O operations: 10
Example • Output results • Number of completed processes: 3 • Number of created processes: 203 • Number of (forced) process switches: 163 • Number of processed I/O operations: 99
Example • Output results • Number of (forced) process switches: 19999 (or 19998)
Example • Output results • Number of (forced) process switches: 19991 • Consider other outputs • Number of completed processes • Number of created processes • Number of processed I/O operations