Krishna iResearch Intelligent Cloud Platform - VIRtual Generic Os - VIRGO - Linux kernel extensions for cloud
 All Classes
virgo_cloud_mempool_main.c
1 /***************************************************************************************
2 VIRGO - a linux module extension with CPU and Memory pooling with cloud capabilities
3 
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 --------------------------------------------------------------------------------------------------
19 Copyright (C):
20 Srinivasan Kannan (alias) Ka.Shrinivaasan (alias) Shrinivas Kannan
21 Independent Open Source Developer, Researcher and Consultant
22 Ph: 9003082186, 9791165980
23 Open Source Products Profile(Krishna iResearch): http://sourceforge.net/users/ka_shrinivaasan
24 Personal website(research): https://sites.google.com/site/kuja27/
25 emails: ka.shrinivaasan@gmail.com, shrinivas.kannan@gmail.com, kashrinivaasan@live.com
26 --------------------------------------------------------------------------------------------------
27 
28 *****************************************************************************************/
29 
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <stdio.h>
33 #include <fcntl.h>
34 #include <unistd.h>
35 #include <string.h>
36 #include <stdlib.h>
37 #include <sys/types.h>
38 #include <sys/wait.h>
39 
40 int main(int argc, char* argv[])
41 {
42  /*
43  int fd=open("/home/kashrinivaasan/linux-3.7.8/drivers/virgo/cpupooling/virgocloudexec/virgo_cloudexec_upcall_usermode_log.txt",O_RDWR | O_APPEND);
44  char buf[500];
45  sprintf(buf,"virgo_cloud_mempool: executing userspace thread for virgo_cloud_mempool on virgo cloud\n");
46  write(fd,buf,sizeof(buf));
47 
48  fsync(fd);
49  close(fd);
50  */
51  int pid;
52  int x=100;
53  int status;
54  x=x*x;
55  pid=fork();
56  void* ptr;
57  if(pid==0)
58  {
59  /*
60  int fd=open("./virgo_cloud_mempool_print_to_stdout.out", O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
61  dup2(fd,1);
62  dup2(fd,2);
63  */
64  printf("Child process of fork: virgo_cloud_mempool_main.c: User space has written to a VFS file opened by Kernel, Kernel To User space communication worksi. Doing userspace malloc(1000)\n");
65  ptr=malloc(1000);
66  fflush(stdout);
67  x=x*x;
68  }
69  else
70  {
71  /*
72  int fd=open("./virgo_cloud_mempool_print_to_stdout.out", O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
73  dup2(fd,1);
74  dup2(fd,2);
75  */
76  printf("Parent process of fork: virgo_cloud_mempool_main.c: User space has written to a VFS file opened by Kernel, Kernel To User space communication works\n");
77  fflush(stdout);
78  x=x*x;
79  waitpid(pid,&status,WCONTINUED);
80  }
81  return NULL;
82 }