1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef IPC_NOTIFICATION_H 13 #define IPC_NOTIFICATION_H 14 15 #include <object/thread.h> 16 17 struct notification { 18 unsigned int not_delivered_notifc_count; 19 unsigned int waiting_threads_count; 20 struct list_head waiting_threads; 21 /* 22 * notifc_lock protects counter and list of waiting threads, 23 * including the internal states of waiting threads. 24 */ 25 struct lock notifc_lock; 26 27 /* For recycling */ 28 int state; 29 }; 30 31 struct irq_notification; 32 33 void init_notific(struct notification *notifc); 34 int wait_notific(struct notification *notifc, bool is_block, 35 struct timespec *timeout); 36 int signal_notific(struct notification *notifc); 37 38 int stop_irq_notific(struct irq_notification *notifc); 39 int wait_irq_notific(struct irq_notification *notifc); 40 int signal_irq_notific(struct irq_notification *notifc); 41 42 void notification_deinit(void *ptr); 43 44 void try_remove_timeout(struct thread *target); 45 46 /* Syscalls */ 47 cap_t sys_create_notifc(void); 48 int sys_wait(cap_t notifc_cap, bool is_block, struct timespec *timeout); 49 int sys_notify(cap_t notifc_cap); 50 51 #endif /* IPC_NOTIFICATION_H */