14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License, Version 1.0 only
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (the "License"). You may not use this file except in compliance
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma D option quiet
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma D option nspec=4
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma D option specsize=100k
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint maxlen;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint spec[int];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsched:::enqueue
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->len = ++qlen[this->cpu = args[2]->cpu_id];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync in[args[0]->pr_addr] = timestamp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsched:::enqueue
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/this->len > maxlen && spec[this->cpu]/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * There is already a speculation for this CPU. We just set a new
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * record, so we'll discard the old one.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync discard(spec[this->cpu]);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsched:::enqueue
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/this->len > maxlen/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * We have a winner. Set the new maximum length and set the timestamp
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * of the longest length.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync maxlen = this->len;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync longtime[this->cpu] = timestamp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Now start a new speculation, and speculatively trace the length.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->spec = spec[this->cpu] = speculation();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync speculate(this->spec);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("Run queue of length %d:\n", this->len);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsched:::dequeue
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/(this->in = in[args[0]->pr_addr]) &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->in <= longtime[this->cpu = args[2]->cpu_id]/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync speculate(spec[this->cpu]);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf(" %d/%d (%s)\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync args[1]->pr_pid, args[0]->pr_lwpid,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync stringof(args[1]->pr_fname));
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsched:::dequeue
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/qlen[args[2]->cpu_id]/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync in[args[0]->pr_addr] = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->len = --qlen[args[2]->cpu_id];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsched:::dequeue
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/this->len == 0 && spec[this->cpu]/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * We just processed the last thread that was enqueued at the time
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * of longest length; commit the speculation, which by now contains
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * each thread that was enqueued when the queue was longest.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync commit(spec[this->cpu]);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync spec[this->cpu] = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}