CMPE 401 - Computer Interfacing

Assignment #1

Due: In the CMPE 401 assignment box at 15:45 on Wednesday, Oct. 6, 2004


  1. Briefly describe the difference between serial and parallel digital interfaces. What are the major advantages and disadvantages of serial versus parallel digital interfaces? Why do you suppose that interfaces for connecting external PC peripherals (e.g., scanners, external hard drives, webcams) are increasingly using serial interfaces such as USB and Firewire instead of parallel interfaces (e.g. the Centronics printer interface)?

  2. What is the purpose of a task control block (TCB) in a kernel or operating system? What task-specific information would one expect to find in the TCB, and what task-specific information would be omitted? What determines which information should be included in the TCB?

  3. In a preemptive multitasking kernel, the various tasks are associated with an ordered set of priorities. The highest-priority ready-to-run task is always supposed to be executing on the CPU (as long as there is no active interrupt being serviced). The kernel software is responsible for enforcing this constraint. What events, therefore, must be monitored by the kernel to allow for the possibility of a context switch from one task to second task with higher priority? Hint: Review the events in lecture slide 3-11.

  4. What is meant by a real-time operating system as opposed to an ordinary operating system? What is the difference between hard real time and soft real time? Give two examples of each kind of real time problem.

  5. A typical human reaction time is about 200 milliseconds. The CPU32 inside the MC68332 microcontroller requires 2 clock cycles to execute the NOP (no operation) instruction. Assuming that the clock frequency is 16.78 MHz, what is the number of NOP instructions that will be executed within one human reaction time?

  6. Design three MicroC/OS-II application tasks in C that share access to a database using a semaphore. The semaphore, called DB_IDLE, is assumed to be initialized to 1 by the start-up task. The first application task, ProducerTask, has an endless loop that alternately calls two functions: GetData and StoreData. GetData has no input arguments, but returns a pointer to a record of type DataType. StoreData has one input argument, a pointer to type DataType, and returns an error code. This error code is 0 if no error occurred, but is 1 if the database was full and could not store the new record (in which case the record is simply discarded). Outside of this critical section, ProducerTask is to update a global integer counter, DB_FULL, that records the number of times that calls to StoreData failed to store a record. StoreData is to lie in one critical section protected by semaphore DB_IDLE.

    The second application task, UpdateTask, has an endless loop that calls three functions in the following order: RetrieveData, UpdateData and StoreData. The three functions are to lie in one critical section protected by semaphore DB_IDLE. RetrieveData has no input argument and returns a pointer to a record of type DataType. The input and output arguments of UpdateData are both pointers to records of type DataType. StoreData has no input argument but produces an output argument that is 0 if a record was added successfully to the database, and is 1 if the record could not be added because the database was full. Outside of this critical section, UpdateTask is to update the global integer counter, DB_FULL, that records the number of times that calls to StoreData failed to store a record.

    The third application task, CleanupData, has an endless loop that calls the function DeleteData ten times per second. DeleteData has no input argument tbut produces an output argument that is 0 if a record was deleted successfully from the database, and is 1 if no record was deleted. Function DeleteData is to be protected by semaphore DB_IDLE. Outside of this critical section, CleanupData is to update a global integer counter, DB_EMPTY, that records the number of times that calls to DeleteData failed to delete a record.

    Your solution to this problem is to contain the begin() initialization routine, the startup task, and all three application tasks. Should the updates to DB_FULL and DB_EMPTY have been protected in critical sections? Are the priorities assigned to the three tasks important to the correct operation of the system?