



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
Department of Electrical Engineering ... 1-page, 1-sided “cheat sheet” may be used. ... Users could waste time on immature software. *.
Typology: Slides
1 / 7
This page cannot be seen from the preview
Don't miss anything!




/
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
#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); }
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”.
*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]
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_B() { compute for 100mu sec.; sleep(2); }
Task_C() { static i=0; compute for 233mu sec.; if(i++ > 1) { halt_me(); } }
Make the following assumptions:
Complete the schedule analysis through at least 7 milliseconds. (chart on next page)
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.
Social: * Uncertainty in business world. * Discourage- ment of entrepreneurship.