



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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Instructions and questions for an exam in computer programming ii, which is part of a bachelor of science (honours) in software development and computer networking degree at cork institute of technology. The exam covers topics such as setting up data structures, linear queues, node representation, sorting algorithms, processes, ipc, threads, semaphores, and sockets.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Bachelor of Science (Honours) in Software Development and Computer Networking - Stage 2 (Bachelor of Science in Software Development and Computer Networking - Stage 2) (NFQ – Level 8)
InstructionsAnswer question 1 and any three others Q1 carries 30 marks, Q2 and Q3 carry 20 markseach; Q4, 5,6 carry 25 marks each. Answer Section A and Section B in separateanswer books.
Examiners: Dr. D. ChambersMr. T. Parslow Mr. P. O’ConnorMs. G. MacSweeney Mr. J. O’Dwyer
Q1. (compulsory) Bank Account Details A bank stores details for 500 customers. Each customer may hold up to 1000 transactions (a) (i) Set up date details unit which holds the following day month year (1 mark) (ii) Set up the transaction unit which holds the following date description amount deposit Or withdrawal Indicatior outgoing balance (2 marks) (iii) Set up the customer details to store the following Name Address Balance All Transactions Ongoing Transaction Number (2marks) Part A Î 5 marks (b) (i) Write the code to set up a linear queue to handle 10 customers at a time emulating customers arriving at a counter in a Bank
(3 marks) (ii) Write the code to insert a customer into a linear queue. On inserting a customer successfully, return 1 otherwise 0 (4 marks) (iii) Write the code to check if the queue is empty, if so return 1 otherwise return 0. (2 marks) Part B Î 9 marks
(c) Main Program (i) Set up an array of customers representing 500 in total representing all the bank customers (1 mark) (ii) Create a new customer with full details and add it to the customer array. Remember you are entering one customer at a time (3 marks) (iii) On entering the bank, assume there is an empty linear queue which has the customers served in turn as they join the end of the queue.
Set smallest = x[ SmallPos ] For j=I +1 to n- if x[j] < smallest Set SmallPos = j; Set smallest = x [SmallPos ] Set x[SmallPos ] = x[I ] Set x[i] = smallest
(i) Y ou are required to display each step involved in making 2 passes through the algorithm 45, 26, 56, 78, 23 (10 marks) (ii) Explain in English how this algorithm works (5 marks) (iii) Compare the above sort routine with the bubbler sort (5 marks)
Question 3 Î 20 marks
Q4. (a) What is a process? Outline two methods by which processes may be created. Compare and contrast the two approaches. Using C type syntax, write a program that will activate the Unix commands ls, who or exit() using a menu-based selection (9 marks) (b) What is IPC? In a UNIX environment, pipes are a well known IPC mechanism. Describe pipes giving their advantages and disadvantages as an IPC mechanism. (6 marks) (c) You are required to set up a system which will allow a user to input a series of character strings in random order and output them in sorted (alphabetic) order. The input process must check that each string is alphabetic before it passes the string to the system SORT routine. A string beginning with XXX marks the end of input. SORT must pass the sorted data to an output process that will print the strings two across the screen. When the end of output is detected the output process will print a count of the number of strings output. Write the code to solve the above problem using C/C type pseudocode. The solution should have three processes that communicate via pipes. (useful C functions are fork(), dup2(), execlp(), sort(), isalpha() ) (10 marks) Q5. (a) What is a thread? Contrast threads and processes. Distinguish between multiplexed threads and bound threads. Draw a state transition for a multiplexed thread. (8 marks)
(b) Outline the steps needed to set-up a client–server application using connection–oriented sockets. A consultancy company wishes to set up a simple system that will allow the company to know when a member is in the building. The system will have a central repository
of names. For each member there will be a name, e-mail address, office, tel-no and status(in/out). When a member enters his/her office, the member starts the client programme that will change the status to in on the central server. The reverse process operates on leaving. The server also notes the entry and exit times and records these in a file with the same name as the member. The file record contains date, time-in and exit-time. The receptionist or any other member can query the repository on any member’s status. The secretary adds new members and updates details on existing members. The repository must allow multiple concurrent users. What synchronisation problem, if any, needs to be addressed in the application? Which synchronisation primitives should be used in this application and why? Assume the application is to be constructed using connection oriented sockets. Sketch the server side solution to the problem using C/C type pseudocode. Your answer should highlight thread and synchronisation level details. (12 marks) (c) Advances in networking technology have made sockets unnecessary. Discuss: (5 marks)