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