System software: operating systems, virtual machines and translation – A Level Computer Science (old syllabus, to 2021) (9608)

28 questions · page 2 of 2

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
16
9608/31/O/N/18 · Question 5Oct/Nov 2018Paper 3111 marks
Loading question…
Question text

5
A computer process can be in one of three states: running, ready or blocked.
(a) Explain how the processes are affected when the following events take place.
(i)
The running process needs to read a file from a disk.
…
…
…
… [2]
(ii)
The running process uses up its time slice.
…
…
…
… [2]
(b) (i)
State the conditions that are necessary for a process to move from the ready to the
running state.
…
…
…
… [2]
(ii)
State the conditions that are necessary for a process to move from the blocked to the
ready state.
…
…
…
… [2]
(c) Give three reasons why process scheduling is needed.
1 …
…
2 …
…
3 …
…
[3]

17
9608/31/O/N/18 · Question 6Oct/Nov 2018Paper 3113 marks
Loading question…
Question text

6
The compilation process has a number of stages. The first stage is lexical analysis.
A compiler uses a keyword table and a symbol table. Part of the keyword table is shown.
•
Tokens for keywords are shown in hexadecimal.
•
All of the keyword tokens are in the range 00 – 5F.
Keyword
Token
01
*
02
=
03
IF
4A
THEN
4B
ENDIF
4C
ELSE
4D
FOR
4E
STEP
4F
TO
50
INPUT
51
OUTPUT
52
ENDFOR
53
Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).
Study the following code.
1
Start
INPUT Number
// Output values in a loop
Start TO 12
FOR Counter
OUTPUT Number * Counter
ENDFOR
(a) Complete the symbol table to show its contents after the lexical analysis stage.
Token
Symbol
Value
Type
Variable
Start
60
Constant
1
61
[3]
(b) The output from the lexical analysis stage is stored in the following table. Each cell stores one
byte of the output.
Complete the output from the lexical analysis stage. Use the keyword table and your answer
to part (a).
60
01
[2]
(c) The output of the lexical analysis stage is the input to the syntax analysis stage.
Identify two tasks in syntax analysis.
1 …
…
2 …
…
[2]
(d) The final stage of compilation is optimisation.
(i)
Code optimisation produces code that minimises the amount of memory used.
Give one additional reason why code optimisation is performed.
…
… [1]
(ii)
A student uses the compiler to compile some different code.
After the syntax analysis stage is complete, the compiler generates object code.
The following lines of code are compiled.
A + B
X
A + B + C
Y
A + B + C + D
Z
The compilation produces the following assembly language code.
LDD
236
//
loads value A to accumulator
ADD
237
//
adds value B to accumulator
STO
512
//
stores accumulator in X
LDD
236
//
loads value A to accumulator
ADD
237
//
adds value B to accumulator
ADD
238
//
adds value C to accumulator
STO
513
//
stores accumulator in Y
LDD
236
//
loads value A to accumulator
ADD
237
//
adds value B to accumulator
ADD
238
//
adds value C to accumulator
ADD
239
//
adds value D to accumulator
STO
514
//
stores accumulator in Z
Rewrite the assembly language code after it has been optimised.
…
…
…
…
…
…
…

18
9608/32/O/N/18 · Question 4Oct/Nov 2018Paper 3215 marks
Loading question…
Question text

4
A compiler uses a keyword table and a symbol table. Part of the keyword table is shown.
•
Tokens for keywords are shown in hexadecimal.
•
All of the keyword tokens are in the range 00 – 5F.
Keyword
Token
01
+
02
=
03
IF
4A
THEN
4B
ENDIF
4C
ELSE
4D
FOR
4E
STEP
4F
TO
50
INPUT
51
OUTPUT
52
ENDFOR
53
Entries in the symbol table are allocated tokens. These values start from 60 (hexadecimal).
Study the following code.
INPUT Number1
INPUT Number2
INPUT Answer
IF Answer = Number1 + Number2
THEN
OUTPUT 10
ELSE
OUTPUT 0
ENDIF
(a) Complete the symbol table to show its contents after the lexical analysis stage.
Token
Symbol
Value
Type
Variable
Number1
60
Variable
Number2
61
[3]
(b) The output from the lexical analysis stage is stored in the following table. Each cell stores one
byte of the output.
Complete the output from the lexical analysis. Use the keyword table and your answer to
part (a).
51
60
[2]
(c) A student uses the compiler to compile some different code.
After the syntax analysis is complete, the compiler generates object code.
The following line of code is compiled:
A + B + C − D
X
The compilation produces the following assembly language code.
LDD
236
//
loads value A into accumulator
ADD
237
//
adds value B to accumulator
ADD
238
//
adds value C to accumulator
STO
540
//
stores accumulator in temporary location
LDD
540
//
loads value from temporary location into accumulator
SUB
239
//
subtracts value D from accumulator
STO
235
//
stores accumulator in X
(i)
Identify the final stage in the compilation process that follows this code generation stage.
… [1]
(ii)
Rewrite the equivalent code following the final stage.
…
…
…
…
…
…
…
… [3]
(iii)
State two benefits of the process that is carried out in the final stage.
Benefit 1 …
…
Benefit 2 …
…
[2]
(d) An interpreter is executing a program. The program uses the variables a, b, c and d.
The program contains an expression that is written in infix form. The interpreter converts the
infix expression to RPN.
The RPN expression is:
b a c + * d + 2 −
The interpreter evaluates this RPN expression using a stack.
The current values are:
a = 1
b = 2
c = 2
d = 3
Show the changing contents of the stack as the interpreter evaluates

Advertisement
19
9608/31/M/J/18 · Question 5May/June 2018Paper 319 marks
Loading question…
Question text

5
The following syntax diagrams show the syntax of:
•
an assignment statement
•
a variable
•
a signed integer
•
a letter
•
a digit
•
an operator
assignment statement
operator
variable
variable
signed integer
=
variable
letter
letter
signed integer
digit
+
-
letter
x
y
z
digit
operator
1
˄
2
\
3
4
5
(a) The following assignment statements are invalid.
Give the reason in each case.
(i)
xy = xy ^ c4
Reason …
… [1]
(ii)
zy = zy \ 10
Reason …
… [1]
(iii)
yy := xz ^ − 6
Reason …
… [1]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams on the opposite page.
<assignment statement> ::=
…
<variable> ::=
…
<signed integer> ::=
…
<operator> ::=
…
[4]
(c) Rewrite the BNF rule for a variable so that it can be any number of letters.
<variable> ::=
… [2]

20
9608/32/M/J/18 · Question 2May/June 2018Paper 3212 marks
Loading question…
Question text

2
The following syntax diagrams show the syntax of:
•
an assignment statement
•
a variable
•
an unsigned integer
•
a letter
•
a digit
•
an operator
assignment statement
;
operator
variable
variable
variable
=
variable
letter
unsigned integer
unsigned integer
digit
letter
A
B
C
digit
operator
+
1
2
-
3
*
4
/
5
(a) The following assignment statements are invalid.
Give the reason in each case.
(i)
A
=
B
+
5;
Reason …
… [1]
(ii)
A
=
B
−
D;
Reason …
… [1]
(iii)
C4
=
B2 − A1 + C3;
Reason …
… [1]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown on the opposite page.
<assignment statement> ::=
…
<variable> ::=
…
<unsigned integer> ::=
…
<operator> ::=
…
[6]
(c) The syntax of variable is changed to allow one or more letters followed by an unsigned
integer.
Draw a syntax diagram for the new syntax of the variable.
[3]

21
9608/31/O/N/17 · Question 3Oct/Nov 2017Paper 3113 marks
Loading question…
Question text

3
The following syntax diagrams for a particular programming language show the syntax of:
an assignment statement
•
a variable
•
an unsigned integer
•
a letter
•
an operator
•
a digit.
•
Assignment statement
Unsigned
Variable
Operator
Variable
:=
integer
Variable
Digit
Letter
Digit
1
Unsigned integer
2
Digit
3
4
Letter
Operator
5
A
+
6
B
–
C
*
7
^
8
9
0
(a) The following assignment statements are invalid.
Give the reason in each case.
(i)
C2 = C3 + 123
Reason: …
… [1]
(ii)
A3 := B1 – B2
Reason: …
… [1]
(iii)
A32 := A2 * 7
Reason: …
… [1]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown.
<digit> has been done for you.
<assignment_statement> ::=
…
<variable> ::=
…
<unsigned_integer> ::=
…
<digit> ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0
<letter> ::=
…
<operator> ::=
…
[6]
(c) The definition of <variable> is changed to allow:
one or two letters and
•
zero, one or two digits.
•
Draw an updated version of the syntax diagram for <variable>.
Variable
Letter
[2]
(d) The definition of <assignment_statement> is altered so that its syntax has
<unsigned_integer> replaced by <real>.
A real is defined to be:
at least one digit before a decimal point
•
a decimal point
•
at least one digit after a decimal point.
•
Give the BNF for the revised <assignment_statement> and <real>.
<assignment_statement> ::= …
…
<real> ::= …
…
[2]

22
9608/32/O/N/17 · Question 3Oct/Nov 2017Paper 3210 marks
Loading question…
Question text

3
(a) This diagram shows how applications P, Q and a software development environment can be
run on a virtual machine system.
Software
Application P
Application Q
development
environment
… A … operating
… A … operating system 1
system 2
Virtual machine software / virtual machine monitor
… B … operating system
Hardware
(i)
State the operating systems labelled A and B in the diagram.
A …
B …
[2]
(ii)
Application P is executing and requests data from a file.
Describe what happens after … A … operating system 1 has received the data request
from the application.
…
…
…
…
…
… [3]
(b) A software development company uses virtual machines to produce software.
(i)
State one benefit to the company.
…
… [1]
(ii)
Explain two limitations of this approach.
Limitation 1 …
…
…
…
Limitation 2 …
…
…
…
[4]

23
9608/32/O/N/17 · Question 4Oct/Nov 2017Paper 3217 marks
Loading question…
Question text

4
The following syntax diagrams for a particular programming language show the syntax of:
•
an unsigned number
•
an unsigned integer
•
a digit.
Unsigned number
Digit
Unsigned
Unsigned
.
1
integer
integer
2
3
Unsigned integer
4
Digit
5
6
7
8
9
0
(a) (i)
Explain why 32 is a valid unsigned integer.
…
…
…
… [2]
(ii)
Explain why 32.5 is a valid unsigned number.
…
…
…
… [2]
(b) Complete the Backus-Naur Form (BNF) for the syntax diagrams shown.
<unsigned_number> ::= …
…
<unsigned_integer> ::= …
…
<digit> ::= …
…
[5]
The format of an unsigned number is amended to include numbers with possible exponents.
If an unsigned number has an exponent, then the exponent part:
•
will start with an ‘E’
•
be followed by an optional ‘+’ or ‘−’ sign
•
and be completed by an unsigned integer.
Examples of unsigned numbers with exponents include: 3E2, 3E+3, 3E−32, 3.45E−2
(c) (i)
Redraw the syntax diagram for unsigned number to include numbers that might have
exponents.
[4]
(ii)
Use your syntax diagram from part (c)(i) to write the BNF for an unsigned number to
include numbers with exponents.
<unsigned_number> ::= …
…
…
…
…
…
…
…

Advertisement
24
9608/31/O/N/16 · Question 2Oct/Nov 2016Paper 3117 marks
Loading question…
Question text

2
There are four stages in the compilation of a program written in a high-level language.
(a) Four statements and four compilation stages are shown below.
Draw a line to link each statement to the correct compilation stage.
Statement
Compilation stage
This stage removes any
comments in the program
Lexical analysis
source code.
This stage could be
Syntax analysis
ignored.
This stage checks the
grammar of the program
Code generation
source code.
This stage produces a
tokenised version of the
Optimisation
program source code.
[4]
(b) Write the Reverse Polish Notation (RPN) for the following expressions.
(A + B) * (C − D)
(i)
… [2]
− A / B * 4 / (C − D)
(ii)
… [3]
(c) An interpreter is executing a program. The program uses the variables w, x, y and z.
The program contains an expression written in infix form. The interpreter converts the infix
expression to RPN. The RPN expression is:
x w z + y − *
The interpreter evaluates this RPN expression using a stack.
The current values of the variables are:
w = 1
x = 2
y = 3
z = 4
(i)
Show the changing contents of the stack as the interpreter evaluates the expression.
The first entry on the stack has been done for you.
2
[4]
(ii)
Convert back to its original infix form, the RPN expression:
x w z + y − *
…
… [2]
(iii)
Explain one advantage of using RPN for the evaluation of an expression.
…
…
…
… [2]

25
9608/31/O/N/16 · Question 3Oct/Nov 2016Paper 3114 marks
Loading question…
Question text

3
A computer operating system (OS) uses paging for memory management.
In paging:
•
main memory is divided into equal-size blocks, called page frames
•
each process that is executed is divided into blocks of the same size, called pages
•
each process has a page table that is used to manage the pages of this process
The following table is the incomplete page table for a process X.
Page
Presence
Page frame address
Additional data
flag
1
1
132
2
1
245
3
1
232
4
0
0
5
1
542
6
0
0
135
0
0
When a particular page of the process is currently in main memory, the Presence flag entry in the
page table is set to 1.
If the page is not currently present in memory, the Presence flag is set to 0.
(a) The page frame address entry for Page 2 is 245.
State what the value 245 could represent.
… [1]
(b) Process X executes until the next instruction is the first instruction in Page 4. Page 4 is not
currently in main memory.
State a hardware device that could be storing this page.
… [1]
(c) When an instruction to be accessed is not present in main memory, its page must be loaded
into a page frame. If all page frames are currently in use, the contents of a page frame will be
overwritten with this new page.
The page that is to be replaced is determined by a page replacement algorithm.
One possible algorithm is to replace the page that has been resident in main memory for the
longest time.
(i)
Give the additional data that would need to be stored in the page table.
…
… [1]
(ii)
Complete the table entries below to show what happens when Page 4 is swapped into
main memory. Assume that Page 5 is the one to be replaced.
In the final column, give an example of the data you have identified in part (c)(i).
Page
Presence
Page frame address
Additional data
flag
4
…
…
…
[3]
An alternative algorithm is to replace the page that has been used least.
(iii)
Give the different additional data that the page table would now need to store.
…
… [1]
(iv)
In the following table, complete the missing data to show what happens when Page 3 is
swapped into main memory. Assume that Page 1 is the one to be replaced.
In the final column, give an example of the data you have identified in part (c)(iii).
Page
Presence
Page frame address
Additional data
flag
3
…
…
…
[3]
(d) Explain why the algorithms given in part (c) may not be the best choice for efficient memory
management.
Longest resident …
…
…
…
Least used …

26
9608/32/O/N/16 · Question 2Oct/Nov 2016Paper 3214 marks
Loading question…
Question text

2
There are four stages in the compilation of a program written in a high-level language.
(a) Four statements and four compilation stages are shown below.
Draw a line to link each statement to the correct compilation stage.
Statement
Compilation stage
This stage can improve the time
Lexical analysis
taken to execute the statement:
x = y + 0
This stage produces object
Syntax analysis
code.
This stage makes use of tree
Code generation
data structures.
This stage enters symbols in
Optimisation
the symbol table.
[4]
(b) Write the Reverse Polish Notation (RPN) for the following expression.
P + Q – R / S
… [2]
(c) An interpreter is executing a program. The program uses the variables a, b, c and d.
The program contains an expression written in infix form. The interpreter converts the infix
expression to RPN. The RPN expression is:
b a * c d a + + -
The interpreter evaluates this RPN expression using a stack.
The current values of the variables are:
a = 2
b = 2
c = 1
d = 3
(i)
Show the changing contents of the stack as the interpreter evaluates the expression.
The first entry on the stack has been done for you.
2
[4]
(ii) Convert back to its original infix form, the RPN expression:
b a * c d a + + -
…
… [2]
(iii)
One advantage of using RPN is that the evaluation of an expression does not require
rules of precedence.
Explain this statement.
…
…
…
… [2]

27
9608/32/O/N/16 · Question 3Oct/Nov 2016Paper 3215 marks
Loading question…
Question text

3
A computer operating system (OS) uses paging for memory management.
In paging:
•
main memory is divided into equal-size blocks, called page frames
•
each process that is executed is divided into blocks of the same size, called pages
•
each process has a page table that is used to manage the pages of this process
The following table is the incomplete page table for a process, Y.
Page
Presence
Page frame address
Additional data
flag
1
1
221
2
1
222
3
0
0
4
0
0
5
1
542
6
0
0
249
0
0
(a) State two facts about Page 5.
1 …
…
2 …
… [2]
(b) Process Y executes the last instruction in Page 5. This instruction is not a branch instruction.
(i)
Explain the problem that now arises in the continued execution of process Y.
…
…
…
…
…
… [2]
(ii)
Explain how interrupts help to solve the problem that you explained in part (b)(i).
…
…
…
…
…
… [3]
(c) When the next instruction is not present in main memory, the OS must load its page into a
page frame. If all page frames are currently in use, the OS overwrites the contents of a page
frame with the required page.
The page that is to be replaced is determined by a page replacement algorithm.
One possible algorithm is to replace the page which has been in memory the shortest amount
of time.
(i)
Give the additional data that would need to be stored in the page table.
…
… [1]
(ii)
Complete the table entry below to show what happens when Page 6 is swapped into
main memory. Include the data you have identified in part (c)(i) in the final column.
Assume that Page

28
9608/31/M/J/16 · Question 3May/June 2016Paper 3110 marks
Loading question…
Question text

3
(a) The following diagram shows how applications X, Y and Z can run on a virtual machine
system.
Application X
Application Y
Application Z
Guest operating
Guest operating system 1
system 2
Virtual machine software / virtual machine monitor
Host operating system
Hardware
(i)
The virtual machine software undertakes many tasks.
Describe two of these tasks.
Task 1 …
…
Task 2 …
… [2]
(ii)
Explain the difference between a guest operating system and a host operating
system.
…
…
…
… [2]
(b) A company uses a computer as a web server. The manufacturer will no longer support the
computer’s operating system (OS) in six months’ time. The company will then need to decide
on a replacement OS.
The company is also considering changing the web server software when the OS is changed.
Whenever any changes are made, it is important that the web server service is not disrupted.
In developing these changes, the company could use virtual machines.
(i)
Describe two possible uses of virtual machines by the company.
Use 1 …
…
…
…
Use 2 …
…
…
… [4]
The web server often has to handle many simultaneous requests.
(ii)
The company uses a virtual machine to test possible solutions to the changes that they
will need to make.
Explain one limitation of this approach.
…
…
…
… [2]

Advertisement