
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document contains exam for System Programming.
Typology: Exams
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Q.1 Write a code segment that associates the port 8652 with a socket corresponding to open file descriptor sock and also sets it in listening mode. (4). Q.2 what happens if a thread function returns status information using static variable instead of dynamically allocation space for it.? (3) Q.3 Compare transmission using UDP and TCP protocol. (4) Q.4 Write a code segment that creates a detached thread. (4) Q.5 Suppose v is a condition variable and m is a mutex. Initialize these variables. Use these in scenario for busy waiting. The predicate is a function test_cond (). Also explain pthread_cond_wait (&v, &m) (6) Q.6 What is critical section and what data structure can be used for dealing critical sections (3) Q.7 Write an a.x file that contains a remote function naming verify_login. The calling entity will pass user login and user password and receives verification in integer variable form representing 1 for true and 0 for false. (6)
Q.1 Write a program that takes a number as command line arguments. Our program will check is this a prime number or not. Use threads for checking all factors i.e. if original number is divisible by particular factor then this are not a prime number. Pass this number and factor as arguments in thread function. Make all the threads joinable. Each thread will return 0 if it is divisible or 1 if not. Main will check if all values equal to 1 then it means it is prime number. (14) Hint: The checking for factor will be in the range 1 to number/2. Q.2 Write a function that blocks all the signals while creating two named pipes and restores all the signals to original state after creating named pipes. The path names are passed as parameters of the function. The prototype for function is as follows: int make_fifos (char *pipe1, char *pipe) (8) Q.3 Write a client program that sends a fixed-length test message to a server and checks that reply is identical to the message sent. (8)