NVMLib  very early alpha
A library to optimally use a Hybrid RAM setup.
uv_loop_demo_example.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <time.h>
#include <unistd.h>
#include <uv.h>
Include dependency graph for uv_loop_demo_example.c:

Go to the source code of this file.

Macros

#define DELETE_LOOP_SLEEP_TIME   5000
 This file is a demo for how object_maintainence.c would work. More...
 
#define MOVE_LOOP_SLEEP_TIME   5000
 
#define MAIN_LOOP_SLEEP_TIME   10000
 
#define ARRAY_SIZE   20
 

Functions

void array_initialise ()
 
void print_array (int arr[], int size, char *msg)
 
void move_from_dram (uv_work_t *req)
 
void move_from_nvram (uv_work_t *req)
 
void delete_from_dram (uv_work_t *req)
 
void delete_from_nvram (uv_work_t *req)
 
void on_after_work (uv_work_t *req, int status)
 
void on_logistics_timer (uv_timer_t *timer, int status)
 
void on_deletion_timer (uv_timer_t *timer, int status)
 
void * logistics_thread_function (void *data)
 
void * deletion_thread_function (void *data)
 
int main ()
 

Variables

int HASHMAP_DRAM [ARRAY_SIZE]
 
int HASHMAP_NVRAM [ARRAY_SIZE]
 
uv_mutex_t nvram_mutex
 
uv_mutex_t dram_mutex
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE   20

Definition at line 27 of file uv_loop_demo_example.c.

◆ DELETE_LOOP_SLEEP_TIME

#define DELETE_LOOP_SLEEP_TIME   5000

This file is a demo for how object_maintainence.c would work.

The idea here is:

  • There are two arrays: 1. HASHMAP_DRAM and
    1. HASHMAP_NVRAM
  • There are two loops: 1. Logistics loop (for moving objects) runs every MOVE_LOOP_SLEEP_TIME secs
    1. Deletion loop (for deleting objects) runs every DELETE_LOOP_SLEEP_TIME secs
  • There is one more thread, thread_maintainer, which is required to run the two loops
  • There main thread prints out the array

Definition at line 23 of file uv_loop_demo_example.c.

◆ MAIN_LOOP_SLEEP_TIME

#define MAIN_LOOP_SLEEP_TIME   10000

Definition at line 25 of file uv_loop_demo_example.c.

◆ MOVE_LOOP_SLEEP_TIME

#define MOVE_LOOP_SLEEP_TIME   5000

Definition at line 24 of file uv_loop_demo_example.c.

Function Documentation

◆ array_initialise()

void array_initialise ( )

Definition at line 34 of file uv_loop_demo_example.c.

◆ delete_from_dram()

void delete_from_dram ( uv_work_t *  req)

Definition at line 81 of file uv_loop_demo_example.c.

◆ delete_from_nvram()

void delete_from_nvram ( uv_work_t *  req)

Definition at line 92 of file uv_loop_demo_example.c.

◆ deletion_thread_function()

void* deletion_thread_function ( void *  data)

Definition at line 157 of file uv_loop_demo_example.c.

Here is the call graph for this function:

◆ logistics_thread_function()

void* logistics_thread_function ( void *  data)

Definition at line 144 of file uv_loop_demo_example.c.

Here is the call graph for this function:

◆ main()

int main ( )

Definition at line 188 of file uv_loop_demo_example.c.

Here is the call graph for this function:

◆ move_from_dram()

void move_from_dram ( uv_work_t *  req)

Definition at line 49 of file uv_loop_demo_example.c.

◆ move_from_nvram()

void move_from_nvram ( uv_work_t *  req)

Definition at line 65 of file uv_loop_demo_example.c.

◆ on_after_work()

void on_after_work ( uv_work_t *  req,
int  status 
)

Definition at line 103 of file uv_loop_demo_example.c.

◆ on_deletion_timer()

void on_deletion_timer ( uv_timer_t *  timer,
int  status 
)

Definition at line 125 of file uv_loop_demo_example.c.

Here is the call graph for this function:

◆ on_logistics_timer()

void on_logistics_timer ( uv_timer_t *  timer,
int  status 
)

Definition at line 108 of file uv_loop_demo_example.c.

Here is the call graph for this function:

◆ print_array()

void print_array ( int  arr[],
int  size,
char *  msg 
)

Definition at line 41 of file uv_loop_demo_example.c.

Variable Documentation

◆ dram_mutex

uv_mutex_t dram_mutex

Definition at line 32 of file uv_loop_demo_example.c.

◆ HASHMAP_DRAM

int HASHMAP_DRAM[ARRAY_SIZE]

Definition at line 28 of file uv_loop_demo_example.c.

◆ HASHMAP_NVRAM

int HASHMAP_NVRAM[ARRAY_SIZE]

Definition at line 29 of file uv_loop_demo_example.c.

◆ nvram_mutex

uv_mutex_t nvram_mutex

Definition at line 31 of file uv_loop_demo_example.c.