Rajib Mall Lecture Notes
-
Upload
anuj-nagpal -
Category
Documents
-
view
52 -
download
6
description
Transcript of Rajib Mall Lecture Notes
![Page 1: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/1.jpg)
1
Software Safety and Halstead’s Software Science (Lecture 16)
Dr. R. Mall
![Page 2: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/2.jpg)
2
Organization of this Lecture:
Software safety: General concepts Fault avoidance Fault detection Fault-tolerance
Halstead’s software scienceSummary
![Page 3: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/3.jpg)
3
Fault-tolerance concepts
Fail safe: design the system so that when it sustains a specified faultit fails in a safe mode
railway signalling systems are designed to be fail safe so that all trains stop.
![Page 4: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/4.jpg)
4
Fault-tolerance concepts
Fail stop: when the system sustains specified faults:provides a subset of its required behavior
![Page 5: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/5.jpg)
5
Software safety
Higher reliability through 3 complementary strategies: fault avoidance:
design time fault tolerance:
execution time fault detection:
implementation and testing time
![Page 6: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/6.jpg)
6
Fault detection
Faults are detected before software put to operation. Verification validation
static dynamic
![Page 7: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/7.jpg)
7
Fault avoidance
Fault avoidance relies on several schemes. appropriately tune
design and implementation process.
![Page 8: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/8.jpg)
8
Fault avoidance
Precise (and preferably formal) specification
Adoption of quality principlesAdoption of a design strategy based
on information hidingUse of a strongly typed
programming languageRestriction on error-prone
programming constructs such as pointers.
![Page 9: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/9.jpg)
9
Fault tolerance
Assumes some residual faults remain. Facilities are provided in software to allow operation to proceed even when faults surface.
![Page 10: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/10.jpg)
10
Strongly typed languages
Strongly typed languages: can detect many of the faults at
compile time.If low level programming with
limited type checking is used. Fault free software production is
virtually impossible.
![Page 11: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/11.jpg)
11
Fault-tolerance
Consists of several aspects: fault detection fault diagnosis damage assessment and containment
fault recovery fault repair
![Page 12: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/12.jpg)
12
Fault detection
The system must detect: a particular state combination has resulted or will result in system failure.
The process of determining that a fault has occurred.
![Page 13: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/13.jpg)
13
Fault diagnosisThe process of determining what caused the fault: i.e. exactly which subsystem or component is faulty.
![Page 14: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/14.jpg)
14
Damage assessment and containmentDetect parts of system:
affected by failure.Prevent propagation of
faults.
![Page 15: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/15.jpg)
15
Fault recovery
The system must restore its state to a known safe state.
Two options available: correct the damaged state
(forward error recovery) restore the system to a known safe
state (backward error recovery)
![Page 16: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/16.jpg)
16
Fault recovery
Forward error recovery is more complex: involves diagnosing faults:
knowing in what state the system should have been: •had the system not failed.
![Page 17: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/17.jpg)
17
Fault repair
Involves modifying the system: In many cases, software failures
are transient:occur due to peculiar combination
of system inputsno repair is necessary as normal
processing can continue immediately after fault recovery.
![Page 18: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/18.jpg)
18
Hardware fault tolerance
Most commonly used hardware fault-tolerance technique: triple modular redundancy (TMR)
![Page 19: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/19.jpg)
19
Triple modular redundancy (TMR)
Module 1
Module 2
Module 3
VotingAgreedresultInput
Result 3
Result 1
![Page 20: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/20.jpg)
20
Triple modular redundancy
Hardware module is replicated three times: output from each unit is compared
voting is used to determine the correct result.
![Page 21: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/21.jpg)
21
Software fault-tolerance
N-version programmingRecovery blocks
![Page 22: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/22.jpg)
22
N-version programming
Different versions of the software implemented by different teams
executed in parallel outputs compared using a voting system:inconsistent outputs are rejected.
![Page 23: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/23.jpg)
23
N-version programming
Version 1
Version 2
Version n
Output comparator
Agreedresult
Input
Result n
Result 1
![Page 24: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/24.jpg)
24
N-version programming
At least three versions of the software should be available
The basic assumption: versions developed by different engineers would not have similar errors.
![Page 25: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/25.jpg)
25
Recovery blocks
A fine grain approachEach program component
includes an acceptance test:
checks if it executed successfully.Acceptance tests cannot determine
what has gone wrong The program components are called
try blocks or recovery blocks.
![Page 26: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/26.jpg)
26
Recovery blocks
Include alternative code: system can backup and execute alternative code
recovery blocks can be cascaded multiple alternatives can be tried when an alternate result also fails acceptance test.
![Page 27: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/27.jpg)
27
Recovery blocks
Algorithm 1
Algorithm 2 Algorithm 1
Acceptance test
retry
test
retrytesttest
result
![Page 28: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/28.jpg)
28
Comparison of n-version programming and recovery block
Unlike n-version programming alternative code is different
rather than independent Also alternative is executed in
sequence rather than parallelBoth suffer from common mode
failure.
![Page 29: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/29.jpg)
29
Exception handling
An exception is an error or an unexpected event
When an exception has not been anticipated: control is transferred to the system exception handling mechanism
![Page 30: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/30.jpg)
30
Exception handling
Many programming languages do not have facility: to detect and handle exceptions.
Languages which support exception handling: Ada, C++, Java
![Page 31: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/31.jpg)
31
Fault detection and damage assessmentThe techniques to be used are
dependent on the application and system state: use of checksums in data exchange
and check digits in numeric data use of redundant links in data
structures which contain pointers use of watchdog timers in concurrent
systems.
![Page 32: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/32.jpg)
32
Checksums
Checksum value computed: by applying some mathematical function to the data.
The function should give unique value for the data.
![Page 33: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/33.jpg)
33
Checksums
Sender computes the checksum: sends the data with the checksum value
receiver computes the checksum again
if the two checksum values differ, the receiver knows that some data have been corrupted.
![Page 34: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/34.jpg)
34
Watchdog timers
Used when a function must complete within a specific time period.
Watchdog timer is a timer: must be reset by the function after it
completes execution. may be interrogated by a controller at
regular intervals if for some reason,
the function does not terminate, the watchdog timer is not reset.
![Page 35: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/35.jpg)
35
Fault recovery
Modify system configuration so that system can continue operationperhaps in some degraded formforward recoverybackward recovery
![Page 36: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/36.jpg)
36
Forward recovery
Correct damaged system state use redundant information with Data corruption: Use coding
technique which add redundant information
Corruption of linked structures: include redundant pointers, e.g both forward and backward pointers.
![Page 37: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/37.jpg)
37
Backward error recovery
Restores system state to a known safe state. Simpler technique than forward error recovery.
most database systems include backward error recovery.
![Page 38: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/38.jpg)
38
Example backward recovery
Computations for a specific user request is known as a transaction. Changes made during a transaction
are not immediately incorporated changes made only after all
computations involved in the transaction finish successfully.
![Page 39: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/39.jpg)
39
Checkpointing
Transactions allow error recovery because they do not commit
changes to the database until they are completed.
However, they do not allow recovery from system states that are valid but incorrect.
Checkpointing can be used.
![Page 40: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/40.jpg)
40
Checkpointing
The system state is duplicated periodically.
When a problem is discovered correct state can be recovered.
![Page 41: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/41.jpg)
41
Safety life cycle
Hazard: A condition with the potential for causing or contributing to a mishap.
e.g, A failure of the sensor which detects an obstacle in front of a machine
![Page 42: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/42.jpg)
42
Hazard Analysis
Analyze the system and its environment detect causes of hazards.
Hazard analysis is difficult because many hazards are extremely rare.
![Page 43: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/43.jpg)
43
Fault-tree analysisFor each identified hazard:
a detailed analysis is carried out to discover the conditions which might cause the hazard.
Fault-tree analysis involves identifying the undesired event working backwards from the event
to discover the possible causes.
![Page 44: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/44.jpg)
44
Fault-tree analysis
The hazard is at the root of the tree: leaves represent potential causes of hazards.
![Page 45: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/45.jpg)
45
Halstead's Software Science
An analytical technique to measure: size, development effort, and development time.
![Page 46: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/46.jpg)
46
Halstead's Software Science
Halstead used primitive program parameters: developed expressions for:
over all program length, potential minimum volume, actual volume, language level, effort, development time.
![Page 47: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/47.jpg)
47
Halstead's Software Science
(CONT.)
For some given program, let:
1 be the number of unique operators used in the program,
2 be the number of unique operands used in the program,
N1 be the total number of operators used in the program,
N2 be the total number of operands used in the program.
![Page 48: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/48.jpg)
48
Halstead's Software Science
(CONT.)
The terms operators and operands have intuitive meanings, a precise definition of these terms is
needed to avoid ambiguities. Unfortunately there is no general
agreement among researchers on definition of operators and
operands:
![Page 49: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/49.jpg)
49
OperatorsSome general guidelines can be
provided: All assignment, arithmetic, and logical
operators are operators. A pair of parentheses,
as well as a block begin --- block end pair, are considered as single operators.
A label is considered to be an operator, if it is used as the target of a GOTO
statement.
![Page 50: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/50.jpg)
50
OperatorsAn if ... then ... else ... endif and a while
... do construct are single operators. A sequence (statement termination)
operator ';' is a single operator. function call
Function name is an operator, I/O parameters are considered as
operands.
![Page 51: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/51.jpg)
51
Halstead's Software Science
(CONT.)
The set of operators and operands for the ANSI C language:() [] . , -> * + - ~ ! ++ -- * / % + - << >> < > <= >= != == & ^ | && || = *= /= %= += -= <<= >>= &= ^= |= : ? { ; CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN and a function name in a function call
![Page 52: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/52.jpg)
52
Halstead's Software Science
(CONT.)
Operands are those variables and constants which are being used with operators in
expressions.Note that variable names appearing
in declarations are not considered as operands.
![Page 53: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/53.jpg)
53
Examples:
In the expression a = &b; {a, b} are operators and { =, &} are operands.
![Page 54: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/54.jpg)
54
Examples:
The function name in a function definition not counted as an operator. int func ( int a, int b )
{ . . .}the operators are: {}, ( )We do not consider func, a, and b as
operands.
![Page 55: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/55.jpg)
55
Examples (CONT.):
In the function call statement: func ( a, b ); {func ( ) ;} are considered as a operator
variables a, b are treated as operands.
![Page 56: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/56.jpg)
56
Length and Vocabulary
Length of a program quantifies total usage of all operators and
operands in the program: Thus, length N=N1+N2.
Program vocabulary: number of unique operators and
operands used in the program.
program vocabulary = 1 + 2 .
![Page 57: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/57.jpg)
57
Program Volume:
The length of a program: total number of operators and
operands used in the code depends on the choice of the
operators and operands, i.e. for the same program, the
length depends on the style of programming.
![Page 58: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/58.jpg)
58
Program Volume:
We can have highly different measures of length for essentially the same problem.
To avoid this kind of problem, the notion of program volume V is
introduced:
V= N log2
![Page 59: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/59.jpg)
59
Potential Minimum Volume:
Intuitively, program volume V denotes minimum number of bits needed to
encode the program.
To represent different identifiers,
we need at least log2 bits ( is the program vocabulary)
![Page 60: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/60.jpg)
60
Potential Minimum Volume:
The potential minimum volume V*: volume of the most succinct program in which the program can be coded.
![Page 61: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/61.jpg)
61
Potential Minimum Volume:
Minimum volume is obtained : when the program can be expressed using a single source code instruction:say a function call like foo().
![Page 62: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/62.jpg)
62
Potential Minimum Volume
(CONT.):Lower bound on volume:
a program would have at least two operators
and no less than the requisite number of operands (i.e. input/output data items).
![Page 63: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/63.jpg)
63
Potential Minimum Volume:
If an algorithm operates on input/output data d1, d2,... dn, the most succinct program is
f(d1,d2, ...,dn);
for which 1 = 2, 2 =n
Therefore, V*=(2+ 2) log2(2+ 2)
![Page 64: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/64.jpg)
64
Potential Minimum Volume:
The program level L is given by L=V*/V.
L is a measure of the level of abstraction: languages can be ranked into
levels that appear intuitively correct.
![Page 65: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/65.jpg)
65
Effort and Time:
Effort E=V/L, where E is the number of mental
discriminations required to write the program
also the effort required to read and understand the program.
![Page 66: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/66.jpg)
66
Effort and Time:
Thus, programming effort E = V2/V* since L= V*/V varies as the
square of the volume. Experience shows
E is well correlated to the effort needed for maintenance.
![Page 67: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/67.jpg)
67
Effort and Time:
The programmer's time T=E/S, where S is the speed of mental
discriminations developed from psychological results due to Stroud,
the recommended value for software is 18.
![Page 68: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/68.jpg)
68
Length Estimation:
Halstead assumed that it is quite unlikely that a program has several identical parts --- or substrings of length greater than
( being the program vocabulary).
![Page 69: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/69.jpg)
69
Length Estimation:In fact, once a piece of code occurs
identically in several places, it is usually made into a procedure or
a function. Thus, we can safely assume:
any program of length N consists of
N/ ) unique strings of length .
![Page 70: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/70.jpg)
70
Length Estimation (CONT.):
It is a standard combinatorial result that for any given alphabet of size K, there are exactly Kr different
strings of length r.
Thus, N/ <
Or, N < +1
![Page 71: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/71.jpg)
71
Length Estimation:
Since operators and operands usually alternate in a program, we can further refine the upper bound into
N < (1)
1 (2)
2 .
![Page 72: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/72.jpg)
72
Length Estimation (CONT.):
Also, N must include not only the ordered set of N elements, but it must also include all possible subsets of that ordered set,
i.e. the power set of N strings.
Therefore, 2N= (1)
1 (2)
2 .
![Page 73: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/73.jpg)
73
Length Estimation:
N=log2((1)
1 (2)
2 ) (approximately)
Or, N=log2 (1)
1 + log2 (2)
2
= 1 log2 1 + 2 log2 2
Experimental analysis of large number of programs suggests: computed and actual lengths match
very closely.
![Page 74: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/74.jpg)
74
Example:
main() { int a,b,c,avg; scanf("%d %d %d",&a,&b,&c); avg=(a+b+c)/3; printf("avg= %d",avg); }
![Page 75: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/75.jpg)
75
Example:
The unique operators are: main, (), \{\}, int, scanf, \&, ",", ";", =, +, /, printf
The unique operands are: a,b,c,\&a,\&b,\&c,a+b+c,avg,3,"\%d \%d \%d", "avg=\%d”
![Page 76: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/76.jpg)
76
Example (CONT.):
Therefore 1=12, 2=11Estimated Length=(12*log12+11*log11) =(12*3.58 + 11*3.45) =(43+38)=81 Volume=Length*log(23)=81*4.52=366
![Page 77: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/77.jpg)
77
SummaryHigh reliability achieved
through 3 complementary strategies: fault avoidance fault tolerance fault detection
Fault tolerance: n-version programming recovery blocks
![Page 78: Rajib Mall Lecture Notes](https://reader035.fdocuments.in/reader035/viewer/2022062307/553131784a7959ae2f8b49a2/html5/thumbnails/78.jpg)
78
SummaryHalstead’s software science
analytical method. Lets us determine:
lengthvolumeefforttime