CORNELL CS 211 - Embedded systems, distributed computing, and threads

Unformatted text preview:

CS211 Spring 2004. Embedded systems, distributed computing, and threads 1Table of contentsIntroduction, 1Microprocessors, 1Real-time simulation, 1Simulating a heating system, 2Threads in Java, 2The SystemClock, 3InsideTemperature, 3IntroductionWe (1) introduce you to the concept of “embeddedsystems”, which can consist of microprocessors that areembedded in larger systems in order to control or sensephysical devices; (2) introduce you to “distributed pro-gramming”, where several different computers are exe-cuting simultaneously, with some form of communica-tion and synchronization between them; and (3) tell youabout execution threads in Java, which allow a Javaprogram to consist of several program segments exe-cuting in parallel.The program that we demo can be obtained from thecourse web page.MicroprocessorsMicroprocessors are small computers, usually em-bedded in other systems. They are used to monitor andregulate the behavior of many common commercialproducts. E.g. dedicated microprocessor systems in carsregulate the fuel-air mixture for combustion and pre-vent skidding (using anti-lock brake systems). In thehome, they appear in appliances such as cellularphones, microwave ovens, and thermostats for heatingand cooling systems. They are used in modems, laserprinters, graphics boards, and disk drives. More exoticapplications include medical instrumentation, guidanceof “smart bombs”, detection of collision and decayevents in high energy particle accelerators.Microprocessors appear in settings where real-timecomputing is necessary: responses to external signals orchanges —which can come at unpredicatable times—must take place within a specific amount of time. Somemicroprocessors must also be able to generate electricalsignals that can be used to control other devices.The anti-lock brake system on a car is a good exam-ple of the challenging nature of real-time computingapplications. A microprocessor must detect changes inthe rotational rates of the wheels characteristic of askid. If the angular velocity of the wheels increases toofast, the tire is slipping on the pavement and the carmay be skidding; controlling the situation may be diffi-cult for the driver. Detecting and correcting this situa-tion involves monitoring the rate of change of the an-gular velocity (i.e. the angular acceleration), not just theangular velocity itself. Upon detecting this situation, themicroprocessor must generate a sequence of outputpulses to control the hydraulic brake system, allowingthe wheels to intermittently rotate to prevent a skid,thus making the car easier to control. Clearly, quickresponse (on the order of tens of milliseconds) to inputsfrom external transducers is essential in this application.Not only must the response be quick, it must be appro-priate for all imaginable driving conditions. For exam-ple, it would unacceptable for the microprocessor tointerfere with normal braking operations at slow speeds.Most real-time programming is done in assemblylanguage or a programming language like C (or C++)that allows the programmer to explicitly manipulate thecontents of specific memory locations. This is becausecommunication with a microprocessor is often donethrough fixed memory locations. The real-time micro-processor itself is often programmed in its native as-sembly language. The machine instructions are placedin the microprocessors memory, which is physicallydistinct from the memory system of the host computer,so that the instructions can be executed autonomouslyby the real-time processor system.Real-time simulationA real-time application may consist of a host com-puter that communicates with several microprocessors,each of which senses some physical property (like thetemperature in a room, or the speed at which a wheel isspinning) or controls some device. The host and an in-dividual microprocessor communicate through a “reg-ister”: —a location in the microprocessor's memory.This location is “mapped” onto a fixed location in thehost processor's memory, so that when the host refer-ences that memory location, it is really referencing themicroprocessor's register. This is why many real-timeapplications need to read and write specific memorylocations.The microprocessor usually has a “program statusword”, or psw, whose bits are used to indicate the statusof the microprocessor. For example, one of the bits, sayC, might be used as follows: When the host computer isready to read a value from the microprocessor's register,it (0) sets bit C to 1, (1) waits until C is set to 0 (by themicroprocessor, to indicate that a new value is in itsregister), and then reads the register. This is how thehost computer and the microprocessor communicateand synchronize.Because of its built-in security measures, Java lacksthe ability to manipulate the contents of specific mem-ory addresses explicitly, so it is not well suited to real-time programming. However, Java does support paral-lelism and provides the tools needed to simulate a real-time computing environment. Our real-time simulationof a home heating system is an example. In it, wesimulate this aspect of communication using a methodreadValue().CS211 Spring 2004. Embedded systems, distributed computing, and threads 2Simulating a heating systemBesides a system output window, our heating sys-tem simulation has five small windows, each of whichrepresents one component of the home heating system:• A clock. You can see the clock “ticking'” away.The period 5000 means that the clock ticks every5,000 milliseconds, or every 5 seconds. You canchange this to a smaller or larger number of milli-seconds by clicking in that text field, typing a newnumber, and pressing button Read period. Theminimum period is 100 milliseconds.• The outside temperature is initially 32 degrees,since this is Ithaca. Typically, a microprocessorwould be attached to a sensor that would detect theoutside temperature. In our simulation, the userchanges the outside temperature by typing a newinteger and pressing button Read temperature.• The furnace is switched on or off by the programas needed. This window just displays its status.There is a button for


View Full Document

CORNELL CS 211 - Embedded systems, distributed computing, and threads

Documents in this Course
B-Trees

B-Trees

10 pages

Hashing

Hashing

3 pages

Load more
Download Embedded systems, distributed computing, and threads
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Embedded systems, distributed computing, and threads and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Embedded systems, distributed computing, and threads 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?