1 / 20

פרק 9 נקודות חשובות בתרגיל 10

פרק 9 נקודות חשובות בתרגיל 10. Guarded Operation. מבנה הפרויקט. הבטים שונים ( OMD1 ) ארכיטקטורה של המערכת-מחלקות. הבטים שונים ( OMD 2 ) מבנה של Composite חשוב. הבטים שונים ( OMD 3 ) בניית המערכת. הבטים שונים ( OMD 4 ) מבנה Packages בלי מחלקות.

Download Presentation

פרק 9 נקודות חשובות בתרגיל 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. פרק 9נקודות חשובות בתרגיל 10 Guarded Operation תיכון תוכנה: ד"ר ראובן גלנט

  2. מבנה הפרויקט תיכון תוכנה: ד"ר ראובן גלנט

  3. הבטים שונים (OMD1)ארכיטקטורה של המערכת-מחלקות תיכון תוכנה: ד"ר ראובן גלנט

  4. הבטים שונים (OMD 2)מבנה של Composite חשוב תיכון תוכנה: ד"ר ראובן גלנט

  5. הבטים שונים (OMD 3)בניית המערכת תיכון תוכנה: ד"ר ראובן גלנט

  6. הבטים שונים (OMD 4)מבנה Packages בלי מחלקות תיכון תוכנה: ד"ר ראובן גלנט

  7. הבטים שונים (OMD 5)מבנה Packages עם מחלקות תיכון תוכנה: ד"ר ראובן גלנט

  8. בניית מערכת (1): <<Singleton>> תיכון תוכנה: ד"ר ראובן גלנט

  9. בניית מערכת (2): Sysמחלקה המיועדת רק לבנות יתר המופעים Sys::Sys() { Adc::getInstance();} תיכון תוכנה: ד"ר ראובן גלנט

  10. בניית מערכת (3): Sensorשילוב בין singleton ל association Sensor::Sensor() {itsAdc = Adc::getInstance();} תיכון תוכנה: ד"ר ראובן גלנט

  11. התנהגות של המערכת: Statecharts תיכון תוכנה: ד"ר ראובן גלנט

  12. פעולות read() של מחלקות Sensor enum eChannel { VOLTAGE, TEMPERATURE, PRESSURE, CALIBRATION }; int PressureSensor::read() {return( 10 * itsAdc->read( PRESSURE ));} int TemperatureSensor::read() { int n; n = itsAdc->read ( TEMPERATURE ); n *= 5; return n; } int VoltageSensor::read() { int n = itsAdc->read( VOLTAGE ); n *= 3; n /= 2; return n; } תיכון תוכנה: ד"ר ראובן גלנט

  13. פעולות read() של מחלקת Adc (1) תיכון תוכנה: ד"ר ראובן גלנט

  14. פעולות read() של מחלקת Adc (2) //file Mux.h class Mux { private: eChannel channel; . . . //etc. } //file Mux.cpp void Mux::select (eChannel aChannel) {channel=aChannel;} //file Adc.h class Adc { public: int value; . . . //etc. } //file Adc.cpp int Adc::read(echannel aChannel) { int i,n; itsMux.select( aChannel ); for ( i=0,n=0; i<8; i++ ) { if ( itsDataIn.isHigh() ) n = ( n << 1 ) + 1; else n = ( n << 1 ) ; } value = n; return n; } //file DataIn.cpp bool DataIn::isHigh() { return ( rand() % 2 == 0{;( bool DataIn::isLow() { return (!isHigh());} תיכון תוכנה: ד"ר ראובן גלנט

  15. Guarded Operation- Mutexs • Rhapsody provides OMProtected which is a mutex (or binary semaphore) for protecting consecutive access to devices. • OMProtected can be used as follows: • attribute OMProtected myMutex; • free myMutex.free(); • lock myMutex.lock(); תיכון תוכנה: ד"ר ראובן גלנט

  16. Unguarded Access to Adc::read() • In the following example, each Sensor calls the Adc::read() operation to measure Voltage / Temperature or Pressure. The read operation selects the appropriate multiplexor input and does eight serial reads on DataIn. תיכון תוכנה: ד"ר ראובן גלנט

  17. Current read() operation is interrupted by another. Unguarded Behavior תיכון תוכנה: ד"ר ראובן גלנט

  18. All operations in a same class, that are guarded will be guarded by the same mutex. Guarding Operations • Rhapsody can use the mutex OMProtected to guard access to a particular operation to stop concurrent access. • This can be done by setting the property concurrency from sequential to guarded. תיכון תוכנה: ד"ר ראובן גלנט

  19. Guarded Behavior Concurrent read() operation is blocked by mutex and is executed when current read() ends. תיכון תוכנה: ד"ר ראובן גלנט

  20. Guarded Operation : Code תיכון תוכנה: ד"ר ראובן גלנט

More Related