/*
 *
 * (C) COPYRIGHT 2010 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU licence.
 *
 * A copy of the licence is included with the program, and can also be obtained
 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 */





digraph policy_objects_diagram {
	rankdir=LR;
	size="12,8";
	compound=true;

	node [ shape = box ];

	subgraph cluster_policy_queues {
		low_queue [ shape=record label = "LowP | {<ql>ctx_lo | ... | <qm>ctx_i | ... | <qr>ctx_hi}" ];
		queues_middle_sep [ label="" shape=plaintext width=0 height=0 ];

		rt_queue [ shape=record label = "RT | {<ql>ctx_lo | ... | <qm>ctx_j | ... | <qr>ctx_hi}" ];

		label = "Policy's Queue(s)";
	}

	call_enqueue [ shape=plaintext label="enqueue_ctx()" ];

	{
		rank=same;
		ordering=out;
		call_dequeue [ shape=plaintext label="dequeue_head_ctx()\n+ runpool_add_ctx()" ];
		call_ctxfinish [ shape=plaintext label="runpool_remove_ctx()" ];

		call_ctxdone [ shape=plaintext label="don't requeue;\n/* ctx has no more jobs */" ];
	}

	subgraph cluster_runpool {

		as0 [ width=2 height = 0.25 label="AS0: Job_1, ..., Job_n" ];
		as1 [ width=2 height = 0.25 label="AS1: Job_1, ..., Job_m" ];
		as2 [ width=2 height = 0.25 label="AS2: Job_1, ..., Job_p" ];
		as3 [ width=2 height = 0.25 label="AS3: Job_1, ..., Job_q" ];

		label = "Policy's Run Pool";
	}

	{
		rank=same;
		call_jdequeue [ shape=plaintext label="dequeue_job()" ];
		sstop_dotfixup [ shape=plaintext label="" width=0 height=0 ];
	}

	{
		rank=same;
		ordering=out;
		sstop [ shape=ellipse label="SS-Timer expires" ]
		jobslots [ shape=record label="Jobslots: | <0>js[0] | <1>js[1] | <2>js[2]" ];

		irq [ label="IRQ" shape=ellipse ];

		job_finish [ shape=plaintext label="don't requeue;\n/* job done */" ];
	}

	hstop [ shape=ellipse label="HS-Timer expires" ]

	/*
	 * Edges
	 */

	call_enqueue -> queues_middle_sep [ lhead=cluster_policy_queues ];

	low_queue:qr -> call_dequeue:w;
	rt_queue:qr -> call_dequeue:w;

	call_dequeue -> as1 [lhead=cluster_runpool];

	as1->call_jdequeue         [ltail=cluster_runpool];
	call_jdequeue->jobslots:0;
	call_jdequeue->sstop_dotfixup [ arrowhead=none];
	sstop_dotfixup->sstop      [label="Spawn SS-Timer"];
	sstop->jobslots            [label="SoftStop"];
	sstop->hstop               [label="Spawn HS-Timer"];
	hstop->jobslots:ne            [label="HardStop"];


	as3->call_ctxfinish:ne [ ltail=cluster_runpool ];
	call_ctxfinish:sw->rt_queue:qm [ lhead=cluster_policy_queues label="enqueue_ctx()\n/* ctx still has jobs */" ];

	call_ctxfinish->call_ctxdone [constraint=false];

	call_ctxdone->call_enqueue [weight=0.1 labeldistance=20.0 labelangle=0.0 taillabel="Job submitted to the ctx" style=dotted constraint=false];


	{
	jobslots->irq   [constraint=false];

	irq->job_finish [constraint=false];
	}

	irq->as2  [lhead=cluster_runpool label="requeue_job()\n/* timeslice expired */" ];

}
