

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
An assignment for a cs 370 course in spring 2009 where students are required to write a multithreaded c program using the pthread library and termcap for low-level terminal control. The goal is to gain experience in writing multithreaded applications and working with character devices. Students will implement a bounded buffer for thread communication, create a mapping from string to sort thread entry functions, develop a screen library using termcap, and use the library in the racer.c file. They will also create a snapshot library for progress messages and start threads for each sorting algorithm.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
CS 370 Spring 2009
For this assignment, you will implement a multithreaded C program that visualizes the differences in running times among a set of sorting algorithms. You will use the pthread library for multithreading and the termcap library for low-level terminal control.
POSIX threads (pthreads) is a POSIX standard for threads. The standard defines an API for creating and manipulating threads. Pthreads are most commonly used on Unix-like POSIX systems such as Linux and Solaris, but Microsoft Windows implementations also exist.
Termcap is an old, low-level facility that abstracts the description and use of computer terminal devices. In the past, terminals were more than windows on the screen, they were physical hardware devices. Operating systems controlled these terminals by sending special text control codes. Each terminal type had (potentially) different control codes for various operations. Termcap defines a set of attributes, including booleans (does the terminal have this property or function?), numbers (how many rows and how many columns?), and strings (what byte sequence do you send to make the terminal do ...?). The facility includes a terminal description “database” and a collection of functions to get and use the information. Read the curs termcap(3x) and termcap(5) manual pages for more information.
The purpose of this assignment is two-fold: to give you experience writing multithreaded applications and to give you experience working with low-level character devices. You will develop a C program that consists of multiple modules (read “source files”). Each module encapsulates a specific “concern” of the application. I have provided you with 12 files: a Makefile, 3 header files, and 8 C source files. Embedded within these files are comments marked with the string TODO. You are to fill in the implementation details for each of these comments. These implementation details will include (not necessarily in this order):
The screen library will use the ioctl() system call to retrieve and set parameters associated with the character device associated with the terminal. See man 2 ioctl for information about the ioctl() system call and man tty ioctl about specifics related to getting and setting terminal attributes. You will be interested in TCGETA and TCSETA.
CS 370 Spring 2009
You will use the function tcsetattr() (man termios) to set parameters associated with the terminal. Specifically, you’ll want to adjust the output mode of the terminal (c oflag) to enable implementation- defined output processing.
Please note: I have left many portions of this assignment abstract – this was intentional. I expect that you may have to spend some time reading the associated manual pages before you’ll be able to complete the assignment. (This is especially true with respect to the termcap portion of the assignment.) My suggestion is to start with the threading code and instead of using the terminfo code, just have your program print progress as separate lines to the screen. Once that’s working, then move on to the terminfo code. Please do not hesitate to ask me questions; I can, if nothing else, point you in the right direction.
After completing the implementation, you are required to schedule a time to meet with me to discuss your implementation. Be prepared to discuss the rational behind the different design choices you make.