Question 61
Question 62
procedure P{x, y, z}; begin y:y+1; z: x+x end; begin a:= b:= 3; P(a+b, a, a); Print(a) end.
Question 63
program sort(...); var a,x,...; procedure readarray; var i,....; begin ...:=a... end; procedure exchange(...); begin ...:=a... ...:=x... end;http://www.cdn.geeksforgeeks.org/wp-admin/profile.php procedure qsort(...); var k,v,...; function partition (...)...; var i,j,...; begin ...:=a... ...:=v... end; begin . . end; begin . . end;Assume that at a given point in time during program execution, following procedures are active: sort, qsort(1,9), qsort(1.3), partition(1,3), exchange(1,3). Show snapshots of the runtime stack with access links after each of the activations.
Question 64
X: CMP R1, 0 ;Compare R1 and 0, set flags appropriately in status register JZ Z ;Jump if zero to target Z MOV R2, R1 ;Copy contents of R1 to R2 SHR R1 ;Shift right R1 by 1 bit SHL R1 ;Shift left R1 by 1 bit CMP R2, R1 ;Compare R2 and R1 and set flag in status register JZ Y ;Jump if zero to target Y INC R3 ;Increment R3 by 1; Y: SHR R1 ;Shift right R1 by 1 bit JMP X ;Jump to target X Z:...a. Initially R1, R2 and R3 contain the value 5, 0 and 0 respectively. What are the final values of R1 and R3 when control reaches Z? b. In general, if R1, R2 and R3 initially contain the values n, 0 and 0 respectively. What is the final value of R3 when control reaches Z?
Question 65
Question 66
Question 67
TEST register, flagThis instruction atomically copies flag to register and sets flag to 1. Give pseudo-code for implementing the entry and exit code to a critical region using this instruction. b. Consider the following solution to the producer-consumer problem using a buffer of size 1. Assume that the initial value of count is 0. Also assume that the testing of count and assignment to count are atomic operations.
Producer: Repeat Produce an item; if count = 1 then sleep; place item in buffer. count = 1; Wakeup(Consumer); Forever Consumer: Repeat if count = 0 then sleep; Remove item from buffer; count = 0; Wakeup(Producer); Consume item; Forever;Show that in this solution it is possible that both the processes are sleeping at the same time.
Question 68
Question 69
EMP(Employee-no, Dept-no, Employee-name, Salary) DEPT(Dept-no, Dept-name, Location)Write an SQL query to: a. Find all employee names who work in departments located at "Calcutta" and whose salary is greater than Rs. 50,000. b. Calculate, for each department number, the number of employees with a salary greater than Rs. 100,000.
There are 70 questions to complete.