You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.3 KiB

  1. /* ----------------------------------------------------------------------------
  2. * SchedMCore - A MultiCore Scheduling Framework
  3. * Copyright (C) 2009-2011, ONERA, Toulouse, FRANCE - LIFL, Lille, FRANCE
  4. *
  5. * This file is part of Prelude
  6. *
  7. * Prelude is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation ; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * Prelude is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY ; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this program ; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  20. * USA
  21. *---------------------------------------------------------------------------- */
  22. #ifndef com_patterns_H_
  23. #define com_patterns_H_
  24. // Description of communication protocols using ultimately periodic
  25. // words: prefix.(periodic pattern). Each communication uses a circular
  26. // buffer shared between the writer and the reader.
  27. // The task instance i writes to the communication buffer iff proto[n]
  28. // is true (modulo the size of the periodic word). After each write, the
  29. // index where the writer writes is incremented.
  30. struct write_proto_t {
  31. int* write_pref;
  32. int wpref_size;
  33. int* write_pat;
  34. int wpat_size;
  35. };
  36. // The task instance n must increment the index at which the task reads
  37. // in the communication buffer iff proto[n] is true (modulo the size of the
  38. // periodic word).
  39. struct read_proto_t {
  40. int* change_pref;
  41. int rpref_size;
  42. int* change_pat;
  43. int rpat_size;
  44. };
  45. /**
  46. * Returns 1 if instance n must write in the com buffer.
  47. */
  48. static inline int must_write(struct write_proto_t wp, int n)
  49. {
  50. if(n < wp.wpref_size)
  51. return wp.write_pref[n];
  52. else
  53. return wp.write_pat[(n-wp.wpref_size)%wp.wpat_size];
  54. }
  55. /**
  56. * Returns 1 if instance n must change the cell from which it reads.
  57. */
  58. static inline int must_change(struct read_proto_t rp, int n)
  59. {
  60. if(n < rp.rpref_size)
  61. return rp.change_pref[n];
  62. else
  63. return rp.change_pat[(n-rp.rpref_size)%rp.rpat_size];
  64. }
  65. #endif