shim_benchmark.c 2.1 KB

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