Changeset e7ac23d0 in mainline
- Timestamp:
- 2017-08-20T14:53:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3f74275
- Parents:
- 49115ac
- Location:
- kernel/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/kobject/kobject.h
r49115ac re7ac23d0 42 42 #define MAX_KERNEL_OBJECTS 64 43 43 44 #define for_each_kobject(task, ko, type) \ 45 for (int i = 0, l = 1; i < MAX_KERNEL_OBJECTS && l; i++) \ 46 for (kobject_t *(ko) = kobject_get((task), i, (type)); \ 47 (ko) && !(l = 0); (ko) = NULL, l = 1) 48 49 #define for_each_kobject_current(ko, type) \ 50 for_each_kobject(TASK, (ko), (type)) 51 44 52 typedef enum { 45 53 KOBJECT_TYPE_INVALID, … … 61 69 struct task; 62 70 71 void kobject_task_alloc(struct task *); 72 void kobject_task_free(struct task *); 73 void kobject_task_init(struct task *); 74 63 75 extern void kobject_initialize(kobject_t *); 64 76 extern kobject_t *kobject_get(struct task *, int, kobject_type_t); … … 67 79 extern void kobject_free(struct task *, int); 68 80 81 extern int kobject_to_cap(struct task *, kobject_t *); 82 69 83 #endif 70 84 -
kernel/generic/src/ipc/ipc.c
r49115ac re7ac23d0 735 735 { 736 736 call_t *call; 737 size_t i;737 bool all_clean; 738 738 739 739 restart: … … 742 742 * Locking is needed as there may be connection handshakes in progress. 743 743 */ 744 for (i = 0; i < MAX_KERNEL_OBJECTS; i++) { 745 phone_t *phone = phone_get_current(i); 746 if (!phone) 747 continue; 744 all_clean = true; 745 for_each_kobject_current(kobj, KOBJECT_TYPE_PHONE) { 746 phone_t *phone = &kobj->phone; 748 747 749 748 mutex_lock(&phone->lock); … … 781 780 if (phone->state != IPC_PHONE_FREE) { 782 781 mutex_unlock(&phone->lock); 782 all_clean = false; 783 783 break; 784 784 } … … 788 788 789 789 /* Got into cleanup */ 790 if ( i == MAX_KERNEL_OBJECTS)790 if (all_clean) 791 791 return; 792 792 … … 820 820 821 821 /* Disconnect all our phones ('ipc_phone_hangup') */ 822 for (int i = 0; i < MAX_KERNEL_OBJECTS; i++) { 823 phone_t *phone = phone_get_current(i); 824 if (!phone) 825 continue; 822 for_each_kobject_current(kobj, KOBJECT_TYPE_PHONE) { 823 phone_t *phone = &kobj->phone; 826 824 ipc_phone_hangup(phone); 827 825 } … … 913 911 printf("[phone cap] [calls] [state\n"); 914 912 915 size_t i; 916 for (i = 0; i < MAX_KERNEL_OBJECTS; i++) { 917 phone_t *phone = phone_get(task, i); 918 if (!phone) 913 for_each_kobject(task, kobj, KOBJECT_TYPE_PHONE) { 914 phone_t *phone = &kobj->phone; 915 int cap = kobject_to_cap(task, kobj); 916 917 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) { 918 printf("%-11d (mutex busy)\n", cap); 919 919 continue; 920 921 if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {922 printf("%-10zu (mutex busy)\n", i);923 continue;924 920 } 925 921 926 922 if (phone->state != IPC_PHONE_FREE) { 927 printf("%-11 zu %7" PRIun " ", i,923 printf("%-11d %7" PRIun " ", cap, 928 924 atomic_get(&phone->active_calls)); 929 925 -
kernel/generic/src/kobject/kobject.c
r49115ac re7ac23d0 37 37 #include <synch/spinlock.h> 38 38 #include <abi/errno.h> 39 #include <mm/slab.h> 39 40 40 41 void kobject_initialize(kobject_t *kobj) … … 42 43 kobj->type = KOBJECT_TYPE_INVALID; 43 44 kobj->can_reclaim = NULL; 45 } 46 47 void kobject_task_alloc(task_t *task) 48 { 49 task->kobject = malloc(sizeof(kobject_t) * MAX_KERNEL_OBJECTS, 0); 50 } 51 52 void kobject_task_init(task_t *task) 53 { 54 for (int cap = 0; cap < MAX_KERNEL_OBJECTS; cap++) 55 kobject_initialize(&task->kobject[cap]); 56 } 57 58 void kobject_task_free(task_t *task) 59 { 60 free(task->kobject); 44 61 } 45 62 … … 91 108 } 92 109 110 int kobject_to_cap(task_t *task, kobject_t *kobj) 111 { 112 return kobj - task->kobject; 113 } 114 93 115 /** @} 94 116 */ -
kernel/generic/src/proc/task.c
r49115ac re7ac23d0 168 168 169 169 list_initialize(&task->threads); 170 171 task->kobject = malloc(sizeof(kobject_t) * MAX_KERNEL_OBJECTS, 0);170 171 kobject_task_alloc(task); 172 172 173 173 ipc_answerbox_init(&task->answerbox, task); … … 190 190 task_t *task = (task_t *) obj; 191 191 192 free(task->kobject);192 kobject_task_free(task); 193 193 return 0; 194 194 } … … 215 215 task->kcycles = 0; 216 216 217 int cap; 218 for (cap = 0; cap < MAX_KERNEL_OBJECTS; cap++) 219 kobject_initialize(&task->kobject[cap]); 217 kobject_task_init(task); 220 218 221 219 task->ipc_info.call_sent = 0; … … 626 624 627 625 if (*additional) { 628 int i;629 for (i = 0; i < MAX_KERNEL_OBJECTS; i++) {630 phone_t *phone = phone_get(task, i);631 if (phone && phone->callee)632 printf(" %d:%p", i,phone->callee);626 for_each_kobject(task, ko, KOBJECT_TYPE_PHONE) { 627 phone_t *phone = &ko->phone; 628 if (phone->callee) 629 printf(" %d:%p", kobject_to_cap(task, ko), 630 phone->callee); 633 631 } 634 632 printf("\n");
Note:
See TracChangeset
for help on using the changeset viewer.