#include <list.h>
#include <stdbool.h>
Go to the source code of this file.
|
| #define | barrier() asm volatile ("" : : : "memory") |
| |
◆ barrier
| #define barrier |
( |
| ) |
asm volatile ("" : : : "memory") |
◆ cond_broadcast()
| void cond_broadcast |
( |
struct condition * |
cond, |
|
|
struct lock * |
lock |
|
) |
| |
416 {
419
422}
#define ASSERT(CONDITION)
Definition: debug.h:30
bool list_empty(struct list *)
Definition: list.c:296
#define NULL
Definition: stddef.h:4
struct list waiters
Definition: synch.h:37
void cond_signal(struct condition *cond, struct lock *lock UNUSED)
Definition: synch.c:396
◆ cond_init()
344 {
346
348}
void list_init(struct list *)
Definition: list.c:58
◆ cond_signal()
◆ cond_wait()
371 {
373
378
380
381
386}
bool intr_context(void)
Definition: interrupt.c:258
void list_insert_ordered(struct list *, struct list_elem *, list_less_func *, void *aux)
Definition: list.c:419
void lock_release(struct lock *lock)
Definition: synch.c:243
void sema_init(struct semaphore *sema, unsigned value)
Definition: synch.c:52
bool lock_held_by_current_thread(const struct lock *lock)
Definition: synch.c:258
static bool cmp_sem_priority(const struct list_elem *a, const struct list_elem *b, void *aux UNUSED)
Definition: synch.c:335
void lock_acquire(struct lock *lock)
Definition: synch.c:202
void sema_down(struct semaphore *sema)
Definition: synch.c:68
◆ donate_priority()
| void donate_priority |
( |
void |
| ) |
|
269 {
272 int nested_depth = 8;
273
274
276 if (nested_depth-- <= 0) break;
278
279
282 else
283 break;
284 }
285}
struct thread * holder
Definition: synch.h:21
int priority
Definition: thread.h:105
struct lock * wait_on_lock
Definition: thread.h:108
struct thread * thread_current(void)
Definition: thread.c:301
int thread_get_priority(void)
Definition: thread.c:441
◆ lock_acquire()
| void lock_acquire |
( |
struct lock * |
lock | ) |
|
202 {
206
211 }
215}
struct semaphore semaphore
Definition: synch.h:22
struct list donations
Definition: thread.h:114
void donate_priority(void)
Definition: synch.c:269
static bool cmp_d_priority(const struct list_elem *, const struct list_elem *, void *aux)
◆ lock_held_by_current_thread()
| bool lock_held_by_current_thread |
( |
const struct lock * |
lock | ) |
|
◆ lock_init()
| void lock_init |
( |
struct lock * |
lock | ) |
|
◆ lock_release()
| void lock_release |
( |
struct lock * |
lock | ) |
|
243 {
246
249
252}
void sema_up(struct semaphore *sema)
Definition: synch.c:114
void remove_with_lock(struct lock *)
Definition: synch.c:289
void refresh_priority(void)
Definition: synch.c:304
◆ lock_try_acquire()
| bool lock_try_acquire |
( |
struct lock * |
lock | ) |
|
224 {
225 bool success;
226
229
231 if (success)
233 return success;
234}
bool sema_try_down(struct semaphore *sema)
Definition: synch.c:90
◆ refresh_priority()
| void refresh_priority |
( |
void |
| ) |
|
304 {
307 int donations_priority;
308
313 donations_priority =
list_entry(donation_elem,
struct thread, d_elem)->priority;
316 }
317}
void list_sort(struct list *, list_less_func *, void *aux)
Definition: list.c:381
struct list_elem * list_begin(struct list *)
Definition: list.c:68
#define list_entry(LIST_ELEM, STRUCT, MEMBER)
Definition: list.h:103
int priority_base
Definition: thread.h:107
◆ remove_with_lock()
| void remove_with_lock |
( |
struct lock * |
lock | ) |
|
289 {
291 struct thread *curr_thread;
292
297 else
299 }
300}
static int next(int pos)
Definition: intq.c:74
struct list_elem * list_remove(struct list_elem *)
Definition: list.c:241
struct list_elem * list_end(struct list *)
Definition: list.c:88
struct list_elem d_elem
Definition: thread.h:115
◆ sema_down()
68 {
70
73
75 while (sema->
value == 0) {
77
79 }
82}
enum intr_level intr_set_level(enum intr_level)
Definition: interrupt.c:130
enum intr_level intr_disable(void)
Definition: interrupt.c:151
intr_level
Definition: interrupt.h:8
unsigned value
Definition: synch.h:9
struct list waiters
Definition: synch.h:10
bool cmp_priority(const struct list_elem *a, const struct list_elem *b, void *aux UNUSED)
Definition: thread.c:449
void thread_block(void)
Definition: thread.c:258
◆ sema_init()
| void sema_init |
( |
struct semaphore * |
sema, |
|
|
unsigned |
value |
|
) |
| |
◆ sema_self_test()
| void sema_self_test |
( |
void |
| ) |
|
141 {
143 int i;
144
145 printf (
"Testing semaphores...");
149 for (i = 0; i < 10; i++)
150 {
153 }
155}
int printf(const char *,...) PRINTF_FORMAT(1
static void sema_test_helper(void *sema_)
Definition: synch.c:159
#define PRI_DEFAULT
Definition: thread.h:30
tid_t thread_create(const char *name, int priority, thread_func *, void *)
Definition: thread.c:197
◆ sema_try_down()
90 {
92 bool success;
93
95
98 {
100 success = true;
101 }
102 else
103 success = false;
105
106 return success;
107}
◆ sema_up()
114 {
116
118
128 else
130 }
131 }
133}
void intr_yield_on_return(void)
Definition: interrupt.c:269
struct list_elem * list_pop_front(struct list *)
Definition: list.c:251
struct list_elem elem
Definition: thread.h:112
void thread_unblock(struct thread *)
Definition: thread.c:275
void thread_yield(void)
Definition: thread.c:343