shim_benchmark.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (C) 2014 Stony Brook University
  2. This file is part of Graphene Library OS.
  3. Graphene Library OS is free software: you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public License
  5. as published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. Graphene Library OS is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. * shim_benchmark.c
  15. *
  16. * Implementation of system call "benchmark_ipc", "send_rpc" and "recv_rpc".
  17. * (These system calls are added for benchmarking purpose.)
  18. */
  19. #include <shim_internal.h>
  20. #include <shim_table.h>
  21. #include <shim_ipc.h>
  22. #include <shim_unistd.h>
  23. #include <shim_profile.h>
  24. #include <errno.h>
  25. int get_pid_port (IDTYPE pid, IDTYPE * dest, struct shim_ipc_port ** port);
  26. int shim_do_benchmark_rpc (pid_t pid, int times, const void * buf,
  27. size_t size)
  28. {
  29. INC_PROFILE_OCCURENCE(syscall_use_ipc);
  30. int ret = 0;
  31. IDTYPE dest;
  32. struct shim_ipc_port * port = NULL;
  33. if ((ret = get_pid_port(pid, &dest, &port)) < 0)
  34. return ret;
  35. ret = ipc_pid_nop_send(port, dest, times, buf, size);
  36. put_ipc_port(port);
  37. return ret;
  38. }
  39. size_t shim_do_send_rpc (pid_t pid, const void * buf, size_t size)
  40. {
  41. return ipc_pid_sendrpc_send(pid, get_cur_tid(), buf, size);
  42. }
  43. int get_rpc_msg (IDTYPE * sender, void * buf, int len);
  44. size_t shim_do_recv_rpc (pid_t * pid, void * buf, size_t size)
  45. {
  46. IDTYPE sender;
  47. int ret = get_rpc_msg(&sender, buf, size);
  48. if (ret < 0)
  49. return ret;
  50. if (pid)
  51. *pid = sender;
  52. return ret;
  53. }