1
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.
Repeat
flag[i]=true;
turn=j;
while (P) do no-op;
Enter critical section, perform actions, then
exit critical section
Flag[i]=false;
Perform other non-critical section actions.
Until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop should be 2
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
Consider the following three C functions:
[P1] int*g(void)
{
int x=10;
return(&x);
}
[P2] int*g(void)
{
int *px;
*px = 10;
return px;
}
[P3] int*g(void)
{
int *px
px =(int*)malloc (size of (int));
*px = 10;
return px;
}
Which of the above three functions are likely to cause problems with pointers?3
GATE CSE 2001
Subjective
+5
-0
Consider the following C program:
(b) If abc(s) is called with a null-terminated string s of length n characters (not counting the null ('\0') character), how many characters will be printed by abc(s)?
void abc(char *s)
{
if(s[0]=='\0') return;
abc(s+1);
abc(s+1);
printf("%c",s[0]);
}
main()
{
abc("123");
}
(a) What will be the output of the program?
(b) If abc(s) is called with a null-terminated string s of length n characters (not counting the null ('\0') character), how many characters will be printed by abc(s)?
4
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
What is printed by the print statements in the program P1 assuming call by
reference parameter passing?
Program P1()
{
x=10;
y=3;
func1(y,x,x);
print x;
print y;
}
func1(x,y,z)
{
y=y+4;
z=x+y+z;
}
Paper analysis
Total Questions
Algorithms
3
Compiler Design
2
Computer Organization
6
Data Structures
2
Database Management System
3
Digital Logic
5
Discrete Mathematics
9
Operating Systems
14
Programming Languages
4
Theory of Computation
6
More papers of GATE CSE
GATE CSE 2024 Set 2
GATE CSE 2024 Set 1
GATE CSE 2023
GATE CSE 2022
GATE CSE 2021 Set 2
GATE CSE 2021 Set 1
GATE CSE 2020
GATE CSE 2019
GATE CSE 2018
GATE CSE 2017 Set 2
GATE CSE 2017 Set 1
GATE CSE 2016 Set 2
GATE CSE 2016 Set 1
GATE CSE 2015 Set 1
GATE CSE 2015 Set 3
GATE CSE 2015 Set 2
GATE CSE 2014 Set 2
GATE CSE 2014 Set 3
GATE CSE 2014 Set 1
GATE CSE 2013
GATE CSE 2012
GATE CSE 2011
GATE CSE 2010
GATE CSE 2009
GATE CSE 2008
GATE CSE 2007
GATE CSE 2006
GATE CSE 2005
GATE CSE 2004
GATE CSE 2003
GATE CSE 2002
GATE CSE 2001
GATE CSE 2000
GATE CSE 1999
GATE CSE 1998
GATE CSE 1997
GATE CSE 1996
GATE CSE 1995
GATE CSE 1994
GATE CSE 1993
GATE CSE 1992
GATE CSE 1991
GATE CSE 1990
GATE CSE 1989
GATE CSE 1988
GATE CSE 1987
GATE CSE
Papers
2023
2022
2020
2019
2018
2013
2012
2011
2010
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997
1996
1995
1994
1993
1992
1991
1990
1989
1988
1987