STORAGE BLOCKS

A CSIM storage block is a resource which can be partially allocated to a requesting process. A storage block consists of a counter (to indicate the amount of available storage) and a queue for processes waiting to receive their requested allocation. A storage set is an array of these basic storage elements. A storage block can be designated to be synchronous. In a synchronous storage block, each allocate is delayed until the onset of the next clock cycle. A set of usage and queueing statistics is automatically maintained for each storage block. These are "printed" whenever a report or a report_storages statement is executed (see “CSIM Report Output” on page 45 for details about the reports that are generated).

Declaring and Initializing Storage

To declare a storage block or set of storage blocks:
STORE s;
STORE array[n];
Where:

  • s - is the variable name representing the storage block (type STORE)
  • array - is the variable name representing the set of storage blocks (array of type STORE)
  • n - is the number of storage blocks in the storage set (type long)
    Notes:
  • STOREs should be declared with global variables in the sim (main) process, prior to the beginning of the simulation part of the model.
  • A STORE must be initialized via the storage or storage_set statement before it can be used in any other statement.

    To initialize a storage block or set of storage blocks:
    s = storage("name", size);
    storage_set(array, "name", size, n);
    Where:

  • s - is the variable name representing the storage block (type STORE)
  • array - is the variable name representing the set of storage blocks (array of type STORE)
  • name - is the name of the storage block or set of storage blocks (quoted string or type char*)
  • size - is the number of units of storage in the (each) storage block (type long)
  • n - is the number of blocks in the storage set (type long)
    Notes:
  • The i-th block in a storage set is named "name[i]".
  • The pointer to the i-th block is stored at array[i].
  • The blocks in the set are indexed 0 through n-1.
  • name is used only for output (reports, status, traces).

    To change the name of a storage block:
    set_name_storage(s, name);
    Where:

  • s - is the storage block or storage set whose name is to be changed (type STORE)
  • name - is the new name for the storage block or storage set (quoted string or type char*)
    Notes:
  • name is used only for output (reports, status, traces).

    Deleting Storage

    To delete a storage block or a storage set:
    delete_storage(s);
    delete_storage_set(array);
    Where:

  • s - is the storage block to be deleted from the model (type STORE)
  • array - is the storage set to be deleted from the model (array of type STORE) Notes:
  • Deleting a storage or storage_set is an extreme action and should be done only when really needed.

    Using Storage

    To allocate some (or all) of the storage in a storage block:
    allocate(amt, s);
    Where:

  • amt - is the amount (number of units) of storage to be allocated (type long)
  • s - is the storage block from which storage is to be allocated (type STORE) Notes:
  • The amount of storage requested (amt) is compared with the amount of storage available at s.
  • If this is sufficient, the amount available is decreased by amt and the requesting process continues.
  • If this is not sufficient, the requesting process is suspended. When storage is deallocated, the highest priority waiting processes are automatically allocated the requested storage (if they fit) and are allowed to continue. The list of waiting processes is searched in priority order until a request cannot be satisfied. In order to preserve priority order, a new request which would fit but which would get in front of higher priority waiting requests will be queued.

    To allocate some (or all) of the storage in a storage block, but only if it can be done within a specified time:
    result = timed_allocate(amt, s, time);
    Where:

  • result - is a returned indication of whether the storage was allocated (type long):
  • EVENT_OCCURRED if the storage was allocated
  • TIMED_OUT if the time limit expired
  • amt - is the amount (number of units) of storage to be allocated (type long)
  • s - is the storage block from which storage is to be allocated (type STORE)
  • time - is the maximum amount of time that the process is willing to wait for storage (type double)
    Notes:
  • The process must check the returned value (result) to determine whether the requested storage was obtained.

    To deallocate storage:
    deallocate(amt, s);
    Where:

  • amt - is the amount (number of units) of storage to be deallocated (type long)
  • s - is the storage block to which storage is to be returned (type STORE)
    Notes:
  • If there are processes waiting, the highest priority processes that are waiting are examined. Those that will now fit have their requests satisfied and then are allowed to continue.
  • If a deallocate operation causes the count of the number of using processes to become negative, an error is detected and execution stops. This occurs whenever more deallocates than allocates are done, regardless of the storage amounts or the number of different processes involved.
  • There is no check to insure that a process returns only the amount of storage that it had been allocated.

    To add more storage to a storage block:
    add_store(size, s);
    Where:

  • size - is the number of units of storage to be added to the storage block (type long)
  • s - is the storage block or storage set whose name is to be changed (type STORE)

    To make storage allocation operations synchronous:
    synchronous_storage(s, phase, period);
    Where:

  • s - is the storage which is to be treated as synchronous (type STORE)
  • phase - is the time to the onset of the first clock cycle (type double)
  • period - is the length of each clock cycle (type double)
    Notes:
  • Synchronized storage causes allocation requests to be delayed until the beginning of a clock cycle.

    Retrieving Storage-Related Information

    These functions each return a statistic which describes some aspect of the usage of the specified storage. The type of the returned value for each of these functions is as indicated. The syntax conventions for these statements are as follows:
  • s - is the storage block about which information is requested. It must be type STORE.
  • a - is a returned value of type char*.
  • n is a returned value of type long.

    Retrieving Static Storage Information

    Statement			Returned Value
    a = storage_name(s);		pointer to name of store s
    n = storage_capacity(s);	number of storage units defined for store s
    
    Retrieving Storage Status Information
    Statement			Returned Value
    

    n = avail(s); number of storage units currently available at store s n = storage_qlength(s); number of processes currently waiting at store s

    Retrieving Storage Summary Information
    Statement			 Returned Value
    

    n = storage_request_amt(s); sum of requested amounts from store s n = storage_number_amt(s); time-weighted sum of requesters for store s n = storage_busy_amt(s); busy time-weighted sum of amounts for store s n = storage_waiting_amt(s); waiting time-weighted sum of amounts for store s n = storage_request_cnt(s); total number of requests for store s n = storage_release_cnt(s); total number of completed requests for store s n = storage_queue_cnt(s); number of queued requests at store s n = storage_time(s); time at store s that is spanned by report

    Reporting Storage Status

    To print the status of each storage block in the model:
    status_storages();
    Notes:

  • This report lists each storage block along with the: