turnstile_types.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2017 Richard Braun.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. *
  18. * Isolated type definition used to avoid inclusion circular dependencies.
  19. */
  20. #ifndef KERN_TURNSTILE_TYPES_H
  21. #define KERN_TURNSTILE_TYPES_H
  22. #include <kern/plist_types.h>
  23. #include <kern/spinlock_types.h>
  24. struct turnstile;
  25. struct turnstile_waiter;
  26. /*
  27. * Per-thread turnstile data.
  28. *
  29. * The turnstile member indicates whether this thread is in a turnstile,
  30. * and is only valid if the thread is not running.
  31. *
  32. * The waiter points to the structure a thread uses to queue itself on
  33. * a turnstile. It is used to access a sleeping thread from another
  34. * thread, e.g. on wake-ups or priority updates.
  35. *
  36. * The list of owned turnstiles is used by priority propagation to
  37. * determine the top priority among all waiters, which is stored in
  38. * the thread data so that turnstiles are quickly unlocked.
  39. *
  40. * Locking keys :
  41. * (b) bucket
  42. * (t) turnstile_td
  43. */
  44. struct turnstile_td
  45. {
  46. struct spinlock lock;
  47. struct turnstile *turnstile; // (t)
  48. struct turnstile_waiter *waiter; // (b,t)
  49. struct plist owned_turnstiles; // (t)
  50. uint32_t top_global_priority; // (t)
  51. uint8_t top_sched_policy; // (t)
  52. uint16_t top_priority; // (t)
  53. };
  54. #endif