/* * The first kthread assigned to a newly activated partition is the one * created by XPC HB with which it calls xpc_activating(). XPC hangs on to * that kthread until the partition is brought down, at which time that kthread * returns back to XPC HB. (The return of that kthread will signify to XPC HB * that XPC has dismantled all communication infrastructure for the associated * partition.) This kthread becomes the channel manager for that partition. * * Each active partition has a channel manager, who, besides connecting and * disconnecting channels, will ensure that each of the partition's connected * channels has the required number of assigned kthreads to get the work done. */ static void xpc_channel_mgr(struct xpc_partition *part) { while (part->act_state != XPC_P_AS_DEACTIVATING || atomic_read(&part->nchannels_active) > 0 || !xpc_partition_disengaged(part)) { xpc_process_sent_chctl_flags(part); /* * Wait until we've been requested to activate kthreads or * all of the channel's message queues have been torn down or * a signal is pending. * * The channel_mgr_requests is set to 1 after being awakened, * This is done to prevent the channel mgr from making one pass * through the loop for each request, since he will * be servicing all the requests in one pass. The reason it's * set to 1 instead of 0 is so that other kthreads will know * that the channel mgr is running and won't bother trying to * wake him up. */ atomic_dec(&part->channel_mgr_requests); (void)wait_event_interruptible(part->channel_mgr_wq, (atomic_read(&part->channel_mgr_requests) > 0 || part->chctl.all_flags != 0 || (part->act_state == XPC_P_AS_DEACTIVATING && atomic_read(&part->nchannels_active) == 0 && xpc_partition_disengaged(part)))); atomic_set(&part->channel_mgr_requests, 1); } }
static void xpc_channel_mgr(struct xpc_partition *part) { while (part->act_state != XPC_P_AS_DEACTIVATING || atomic_read(&part->nchannels_active) > 0 || !xpc_partition_disengaged(part)) { xpc_process_sent_chctl_flags(part); /* */ atomic_dec(&part->channel_mgr_requests); (void)wait_event_interruptible(part->channel_mgr_wq, (atomic_read(&part->channel_mgr_requests) > 0 || part->chctl.all_flags != 0 || (part->act_state == XPC_P_AS_DEACTIVATING && atomic_read(&part->nchannels_active) == 0 && xpc_partition_disengaged(part)))); atomic_set(&part->channel_mgr_requests, 1); } }