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