Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Software Development and Computer Networking Exam - Computer Programming II (Autumn 2005), Exams of Computer Engineering and Programming

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

2012/2013

Uploaded on 03/28/2013

duraid
duraid 🇮🇳

4.3

(3)

55 documents

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download Software Development and Computer Networking Exam - Computer Programming II (Autumn 2005) and more Exams Computer Engineering and Programming in PDF only on Docsity! Cork Institute of Technology 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) Autumn 2005 Computer Programming II (Time: 3 Hours) Instructions Answer question 1 and any three others Q1 carries 30 marks, Q2 and Q3 carry 20 marks each; Q4, 5,6 carry 25 marks each. Answer Section A and Section B in separate answer books. Examiners: Dr. D. Chambers Mr. T. Parslow Mr. P. O’Connor Ms. G. MacSweeney Mr. J. O’Dwyer Section A 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 2 (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. • Ask for the customer Account number & Check that the customer is present in the customer array • Copy the customer from the customer array and insert into the linear queue • On arrival at the counter, remove from the queue • Make a transaction for making a deposit 30 euro. • Ensure that you add the date, description, deposit amount and update the balance using the balance from the customer. • Note if a deposit, set the deposit indicator to 1 otherwise 0; • Add the transaction to the customer’s set of transaction • Update the customer’s overall balance (12 marks) Part C 17 marks Question 1 == 30 marks 5 Section B 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) 6 (b) What is a semaphore? Outline the characteristics of UNIX semaphores. Contrast UNIX semaphores with the classical binary semaphores of Computer Science. Semaphores are a useful synchronisation tool but are not sufficient by themselves to solve the critical section problem. Why? (8 marks) (c) It is required, in a multi-threaded server that all errors/exceptions raised are written to a log-file. One thread, the errLog thread, has responsibility for the log file. All other threads write the error, as a text string, to a buffer, which is shared between all threads. The buffer is to be 1024 bytes long and an error message is to have a maximum length of 100 bytes terminated by a #. This means that the buffer can hold a minimum of ten error messages. The errLog thread will check the buffer and if new messages have arrived, it copies the buffer contents to a separate area and resets the buffer to empty. The errLog thread can then write the copy of the buffer to the file. Sketch a solution to the above problem using C/C++ or pseudocode. Your answer should highlight thread and synchronisation level details. (10 marks) Q6. (a) What is a socket? Describe the address structure used by an Internet type socket? Explain how a server name can be resolved to an IP address. Outline the code that would allow a client program to enter the server name as a command line argument. E.G. whois cromlech, where cromlech is the Unix server. (8 marks) 7 (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)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved