Krishna iResearch Intelligent Cloud Platform - KingCobra - Byzantine request servicing software
 All Namespaces
kingcobra_main.c
1 /***************************************************************************************
2 KingCobra - Byzantine Fault Tolerant Request Servicing Software with Queues and Arbiters
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 -----------------------------------------------------------------------------------------------------------------------------------
20 Srinivasan Kannan (alias) Ka.Shrinivaasan (alias) Shrinivas Kannan
21 Independent Open Source Developer, Researcher and Consultant
22 Ph: 9789346927, 9003082186, 9791165980
23 Krishna iResearch Open Source Products Profiles:
24 http://sourceforge.net/users/ka_shrinivaasan,
25 https://www.ohloh.net/accounts/ka_shrinivaasan
26 Personal website(research): https://sites.google.com/site/kuja27/
27 emails: ka.shrinivaasan@gmail.com, shrinivas.kannan@gmail.com,
28 kashrinivaasan@live.com
29 -----------------------------------------------------------------------------------------------------------------------------------
30 *****************************************************************************************/
31 
32 /*
33 Userspace library that contains function definitions for KingCobra commands. VIRGO linux workqueue
34 handler is invoked on the work_structs pushed (push_request()) and does upcall to this userspace
35 binary. (This is similar to VIRGO kernel upcall functionality in cpupooling and memorypooling kernel modules).
36 */
37 
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <dlfcn.h>
43 #include <pthread.h>
44 #include <fcntl.h>
45 #include <unistd.h>
46 
47 int main(int argc, char **argv)
48 {
49  void *handle;
50  void* (*kingcobra_function)(void*);
51  char *error;
52  pthread_t tid;
53  void* x;
54 
55  int s=0;
56 
57  handle = dlopen("/home/kashrinivaasan/linux-3.7.8/drivers/virgo/queuing/libkingcobra_commands.so", RTLD_LAZY);
58  if (!handle) {
59  fprintf(stderr, "%s\n", dlerror());
60  exit(EXIT_FAILURE);
61  }
62 
63  dlerror(); /* Clear any existing error */
64 
65  printf("dlsym lookup for kingcobra function: %s\n", argv[1]);
66  *(void **) (&kingcobra_function) = dlsym(handle, argv[1]);
67  /* *(void **) (&cloud_function) = dlsym(handle, "_Z16virgo_cloud_testPv");*/
68 
69  if ((error = dlerror()) != NULL) {
70  fprintf(stderr, "%s\n", error);
71  exit(EXIT_FAILURE);
72  }
73  printf("KingCobra userspace library: spawning userspace thread for KingCobra function pointer: %x\n",kingcobra_function);
74  int args=1000;
75  s=pthread_create(&tid, NULL, kingcobra_function, &args);
76  pthread_join(tid, &x);
77  fflush(stdout);
78  dlclose(handle);
79 
80  exit(EXIT_SUCCESS);
81 }