INSEE 05.04.2011
Interconnection Nertworks Simulation and Evaluation Environment
Functions | Variables
C:/cygwin/home/Javier/insee/src/pkt_mem.c File Reference

Definition of FSIN functions for packet management. More...

#include "globals.h"
#include "packet.h"
Include dependency graph for pkt_mem.c:

Functions

void pkt_init ()
void free_pkt (unsigned long n)
unsigned long get_pkt ()

Variables

packet_tpkt_space
long pkt_max
long * f_pkt
long last

Detailed Description

Definition of FSIN functions for packet management.

Author:
Javier Navaridas

FSIN Functional Simulator of Interconnection Networks Copyright (2003-2011) J. Miguel-Alonso, J. Navaridas

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


Function Documentation

void free_pkt ( unsigned long  n)

Frees a packet.

Add the packet id. to the free packets

Parameters:
nThe id of the packet to free.
unsigned long get_pkt ( )

Get a free packet.

Returns:
The id of the last used free packet.
void pkt_init ( )

Initiates the memory allocation & the free packets structure.

In pkt_space we allocate all the space needed for packet contain. This way our Memory needs are always the same and we must not alloc and free memory each time we use a packet.


Variable Documentation

long* f_pkt

A list with ids of all the free packets.

long last

The last position in use on the list.

long pkt_max

The maximum number of packets allowed.

Normally is the number of nodes multiplied by the maximun capacity of each router.

Structure in wich all the packets are stored.

It is created and allocated when stating simulation, and it must be not modify later. It is used in heap mode, so we try to use the last free packet to favor spatial locality.

See also:
pkt_init