EE472 Mid Term, Slides of Software Engineering

Department of Electrical Engineering ... 1-page, 1-sided “cheat sheet” may be used. ... Users could waste time on immature software. *.

Typology: Slides

2022/2023

Uploaded on 05/11/2023

eknathia
eknathia 🇺🇸

4.4

(26)

264 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EE472 Mid Term
SOLUTION KEY
Prof. Blake Hannaford
Department of Electrical Engineering
The University of Washington
29-Oct-2008
/
NAME
Rules
Individual Work
Closed Book, Closed Notes, No Calculators
1-page, 1-sided “cheat sheet” may be used. Original material only. No copying of exam solutions into
cheat sheet.
1 hour (and 10 minutes)
60 points
Score Distribution:
1
pf3
pf4
pf5

Partial preview of the text

Download EE472 Mid Term and more Slides Software Engineering in PDF only on Docsity!

EE472 Mid Term

SOLUTION KEY

Prof. Blake Hannaford

Department of Electrical Engineering

The University of Washington

29-Oct-

/

NAME

Rules

  • Individual Work
  • Closed Book, Closed Notes, No Calculators
  • 1-page, 1-sided “cheat sheet” may be used. Original material only. No copying of exam solutions into cheat sheet.
  • 1 hour (and 10 minutes)
  • 60 points

Score Distribution:

1 C Programming (20 pts)

Write a C function to detect if a 32 bit integer contains the “target sequence” of bits at any point. For example, if the target sequence is 110101 ,

1010 1010 1010 1010 1010 1010 1010 1010 does NOT contain 110101 1111 0001 1010 1000 1101 1110 0111 1100 DOES contain 110101 ^ ^^^^ ^

Your algorithm should use bit-wise logic to solve this problem Note: The target sequence can be represented in a 32-bit integer, but only the bits to the right of the first 1 looking from the MSB “count”. For example, for our 6-bit target above:

0000 0000 0000 0000 0000 0000 0011 0101 = 0x these don’t count: [------------------------------] these count: [-----]

Your algorithm should take as a parameter the number of bits in the target. Function prototype of solution:

int patterncheck(unsigned int word, unsigned int target, int nbits); // returns 1 if the pattern is found, 0 otherwise

Solution

#define MSB 0x int patterncheck(unsigned int number, unsigned int target, int nbits) { int i,j,k; unsigned int mask;

// first let’s generate a bit mask which identifies which bits we are comparing mask = 0; for(j=nbits; j>0 ; j--) { mask = (mask << 1) | 1; } // Now we slide the number to the right and compare. i=32; while(i>0) { if((number & mask) == target) { return(1); } number = number >> 1; i--; } return(0); }

3 Pointers (10 pts)

For the following declarations and statements,

// declarations int i1, i2, i3, *ip1, *ip2, *ip3; char c1,c2,c3; static char s[]="Here is a string";

// assignment statements ip1 = &i1; ip2 = &i2; ip3 = &i3; i1 = 94; i2 = -67; i3 = 42;

Evaluate the following expressions (if the expression is a syntax (compiler) error, indicate that with “X”. If it will compile OK, but produce an error or invalid output when it runs, mark “E”.

Solution

*ip1-4 = 90 ERROR: ip1-4 = %d\n", ip1-4); "E" (ip2+67) = -1080922471 "E" (s+5) = [is a string] (int)(s+16) = 0 (s+5) = [is]

4 Schedulers (15 pts.)

Consider the following three tasks with a non-preemptive, round robin scheduler WITH synchronization. As we discussed in class: Consider P, and D to be specifications and C a resource requirement. After charting the schedule, are P and D satisfied?

  • Task A C = 233μsec, P=1ms, D=0.5ms.
  • Task B C = 100μsec, P=2ms, D=2ms.

Task_B() { compute for 100mu sec.; sleep(2); }

  • Task C C = 233μsec, P=1ms, D=1ms.

Task_C() { static i=0; compute for 233mu sec.; if(i++ > 1) { halt_me(); } }

Make the following assumptions:

  • Functions sleep(n) and halt me() exist as described in class.
  • A static variable is initialized only once, before the function is executed for the first time.
  • The scheduler takes 100μsec of CPU time.
  • Assume scheduler starts for the first time at t = 0μsec.
  • As in class, make each horizontal line represent 333μsec.

Complete the schedule analysis through at least 7 milliseconds. (chart on next page)

5 Open Source Software (5pts)

Comment on the social and economic costs and benefits of open source software such as the development tools we are using in the lab in EE472. Consider economic benefits and costs to be those which can be directly measured in terms of money. While social costs and benefits refer to the general welfare of society. Please try to think of at least one cost and benefit in each category. Short answers or “bullet points” are sufficient.

There are lots of good answers to these questions. I’m looking here for some evidence of broad thinking about these questions, for making links to “the bigger picture”. Costs Benefits Economic: * There could be costly disruption to existing SW companies. Shrinking payrolls, lost profits. * Users could waste time on immature software. * No guarantees. * No phone number to call for tech support. May require more hours from internal IT staff.

  • Users don’t pay for SW. * Free support from chat-boards can save on support costs.

Social: * Uncertainty in business world. * Discourage- ment of entrepreneurship.

  • Online communities form around projects. * Equal access to software for poor nations/people * Open sharing of ideas and solutions to problems.
  • Software can emerge to serve niche groups.