InClassActivity18-sol - Activity #18 (Solution) 3/28/2003...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
ECSE-2660 Computer Architecture, Networks, & Operating Systems, Spring 2003 Page 1 of 2 Activity #18 (Solution) 3/28/2003 3:24 AM Activity 18.1 Operating system concepts 1. The following C-like code is to be executed. The code takes integer values from user until the user enters a negative value, and then it outputs the average of the entered values. The program is allotted memory space from 1000 to 2000 in terms of words. 1 int sum=0, n, i=0; 2 while (1) { 3 scanf (“%d\n”, &n); // get the next value from user 4 if (n < 0) break; 5 sum = sum + n; 6 i = i + 1;} 7 avg = sum / i; 8 printf (“%d\n”, avg); 1a. (5 points) What are the base and limit registers for the above program? The base and limit register values are both equal to 1000. Grading: 1pt for trying. +2pts for each correct register value. 1b. (10 points) Which lines will definitely trap the operating system? Explain why. Refer to the line numbers given at the left side of each line of code. Line #3 will definitely trap OS, because it requires input from keyboard which is an I/O device. Note that line #8 may NOT trap depending on what the user enters. See answer to the next part. Grading: 2points for trying. +4pts for correctly defined line w/o reasonable explanation, +4pts for reasonable explanation. -3pts for any wrong and extra line. 1c. (10 points) Which lines may
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course ECSE ecse-2340 taught by Professor Wozny during the Spring '09 term at Rensselaer Polytechnic Institute.

Page1 / 2

InClassActivity18-sol - Activity #18 (Solution) 3/28/2003...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online