--- Gnu-Mach/kern/processor.c 2020/09/02 04:36:56 1.1 +++ Gnu-Mach/kern/processor.c 2020/09/02 04:45:12 1.1.1.3 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1993-1988 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -27,17 +27,18 @@ * processor.c: processor and processor_set manipulation routines. */ -#include -#include -#include +#include #include #include #include #include #include +#include +#include #include #include +#include #include #include #include @@ -46,8 +47,8 @@ #include #if MACH_HOST -#include -zone_t pset_zone; +#include +struct kmem_cache pset_cache; #endif /* MACH_HOST */ @@ -112,10 +113,10 @@ void pset_sys_init(void) register processor_t processor; /* - * Allocate the zone for processor sets. + * Allocate the cache for processor sets. */ - pset_zone = zinit(sizeof(struct processor_set), 128*PAGE_SIZE, - PAGE_SIZE, 0, "processor sets"); + kmem_cache_init(&pset_cache, "processor_set", + sizeof(struct processor_set), 0, NULL, NULL, NULL, 0); /* * Give each processor a control port. @@ -329,7 +330,7 @@ void thread_change_psets( queue_enter(&new_pset->threads, thread, thread_t, pset_threads); thread->processor_set = new_pset; new_pset->thread_count++; -} +} /* * pset_deallocate: @@ -362,7 +363,7 @@ void pset_deallocate( */ pset->ref_count = 1; pset_ref_unlock(pset); - + simple_lock(&all_psets_lock); pset_ref_lock(pset); if (--pset->ref_count > 0) { @@ -394,7 +395,7 @@ void pset_deallocate( /* * That's it, free data structure. */ - zfree(pset_zone, (vm_offset_t)pset); + kmem_cache_free(&pset_cache, (vm_offset_t)pset); #endif /* MACH_HOST */ } @@ -440,7 +441,7 @@ processor_info( else basic_info->running = TRUE; basic_info->slot_num = slot_num; - if (processor == master_processor) + if (processor == master_processor) basic_info->is_master = TRUE; else basic_info->is_master = FALSE; @@ -538,7 +539,7 @@ processor_set_create( if (host == HOST_NULL) return KERN_INVALID_ARGUMENT; - pset = (processor_set_t) zalloc(pset_zone); + pset = (processor_set_t) kmem_cache_alloc(&pset_cache); pset_init(pset); pset_reference(pset); /* for new_set out argument */ pset_reference(pset); /* for new_name out argument */ @@ -613,7 +614,7 @@ kern_return_t processor_set_destroy( pset_lock(pset); } } - + if (pset->processor_count > 0) { list = &pset->processors; while(!queue_empty(list)) { @@ -639,7 +640,7 @@ kern_return_t processor_set_destroy( } #else /* MACH_HOST */ - + kern_return_t processor_set_create( host_t host, @@ -661,7 +662,7 @@ kern_return_t processor_set_destroy( return KERN_FAILURE; } -#endif MACH_HOST +#endif /* MACH_HOST */ kern_return_t processor_get_assignment( @@ -975,7 +976,7 @@ processor_set_things( return KERN_RESOURCE_SHORTAGE; } - bcopy((char *) addr, (char *) newaddr, size_needed); + memcpy((void *) newaddr, (void *) addr, size_needed); kfree(addr, size); addr = newaddr; }