-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_virgo_malloc.c
105 lines (90 loc) · 3.41 KB
/
test_virgo_malloc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************************
#---------------------------------------------------------------------------------------
#NEURONRAIN VIRGO - Cloud, Machine Learning and Queue augmented Linux Kernel Fork-off
#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 3 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, see <http://www.gnu.org/licenses/>.
#----------------------------------------------------------------------------------------
#Copyleft (Copyright+):
#Srinivasan Kannan (alias) Ka.Shrinivaasan (alias) Shrinivas Kannan
#Ph: 9791499106, 9003082186
#Krishna iResearch Open Source Products Profiles:
#http://sourceforge.net/users/ka_shrinivaasan,
#https://github.com/shrinivaasanka,
#https://www.openhub.net/accounts/ka_shrinivaasan
#Personal website(research): https://sites.google.com/site/kuja27/
#emails: ka.shrinivaasan@gmail.com, shrinivas.kannan@gmail.com,
#kashrinivaasan@live.com
#----------------------------------------------------------------------------------------
*****************************************************************************************/
#include <stdio.h>
#include <syscall.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
struct virgo_address
{
int node_id;
struct hostport* hstprt;
void* addr;
};
struct hostport
{
char* hostip;
int port;
};
void virgo_systemcalls(pthread_mutex_t* lock,int process);
int main(int argc, char* argv[])
{
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutexattr_t mattr;
pthread_mutex_init(&lock,NULL);
pthread_mutexattr_init(&mattr);
pthread_mutexattr_setpshared(&mattr,PTHREAD_PROCESS_SHARED);
/*
virgo_malloc(), virgo_set(), virgo_get() and virgo_free() syscalls called by syscall numbers
- Ka.Shrinivaasan
*/
int pret=fork();
virgo_systemcalls(&lock,pret);
}
void virgo_systemcalls(pthread_mutex_t* lock,int process)
{
int iterations=0;
while(iterations++ < 100)
{
pthread_mutex_lock(lock);
printf("process id: %d\n",process);
unsigned long long virgo_unique_id;
/* virgo_malloc */
/*syscall(384,100,&virgo_unique_id);*/
syscall(549,100,&virgo_unique_id);
printf("vuid malloc-ed : %llu \n",virgo_unique_id);
/* virgo_set */
char set_data[256];
if(process==0)
strcpy(set_data,"DataSet_process1");
else
strcpy(set_data,"DataSet_process2");
printf("virgo_set() data to set for vuid %llu : %s\n",virgo_unique_id,set_data);
/*long set_ret=syscall(385,virgo_unique_id,set_data);*/
long set_ret=syscall(550,virgo_unique_id,set_data);
/*virgo_get*/
char get_data[256];
/*long get_ret=syscall(386,virgo_unique_id,get_data);*/
long get_ret=syscall(551,virgo_unique_id,get_data);
printf("virgo_get() data for vuid %llu : %s\n",virgo_unique_id,get_data);
/*virgo_free*/
/*long free_ret=syscall(387,virgo_unique_id);*/
long free_ret=syscall(552,virgo_unique_id);
printf("vuid freed : %llu \n",virgo_unique_id);
pthread_mutex_unlock(lock);
}
}