220 likes | 335 Views
An Extensible Choices System Interface. Adam Boot, Weihang Jiang, Manlap Li, Rodolfo Pellizzoni, Enzhou Wang CS 523 Spring, 2006. Motivation. Choices in the beginning of semester… only runs assembly programs many sys objs, many constants to look up single-threaded programs only. Outline.
E N D
An Extensible Choices System Interface Adam Boot, Weihang Jiang, Manlap Li, Rodolfo Pellizzoni, Enzhou Wang CS 523 Spring, 2006
Motivation • Choices in the beginning of semester… • only runs assembly programs • many sys objs, many constants to look up • single-threaded programs only
Outline • Proxies & Automatic Generation • Multithreading • Conclusion • Future Work
Original Implementation • Export proxy classes to application space • Automatically generated by a C++ preprocessor program • Proxy methods invoked in application space trap into the kernel • Kernel dispatcher catches the call and executes the appropriate method
Application Kernel Trap System Call Application Proxy Kernel Dispatcher Kernel Method
Problems • Implementation was not only machine-dependent, but also compiler-dependent • Currently does not work due to compiler changes • Allowed system calls using application defined subclasses • The kernel makes calls into application defined code • We feel this is unnecessary, potentially dangerous, and bad for performance
Our Implementation • Provides the same proxy and dispatcher mechanism • Does not allow subclasses to trap inside the kernel • Use an IDL compiler to generate the proxies and dispatchers • Midterm prototype interface was hand coded • Not maintainable • Repetitive to code
Benefits of IDL • Compiler-independent • Allows a language-independent description of the interface • Extensible and maintainable • Automatically generate code based on kernel classes • Classes that inherit from 'ProxiableObject‘ • Methods that are marked 'proxiable' • Can fairly easily produce a system interface library for other languages
Benefits of Our Design • No machine-dependent kernel code and limited amount in application code • Performance: No parameters need to be copied from application to kernel • Security: Kernel detects errors in system calls and passes exceptions back to application • Automatic garbage collection of kernel objects
Tools and Design • CORBA compliant IDL compiler from omniORB • Free, licensed under GPL • Easily extensible using C++ and Python to create back-end modules for code generation • Python back-ends for the IDL compiler to produce application proxies and kernel dispatchers • Python application to parse kernel header files to produce an IDL specification file
Choices Kernel Header Files IDL Specification File Parser Application Proxies OmniIDL Compiler Application Back-End Kernel Dispatchers Kernel Back-End
Generated Code • Application Library Headers • Mirror the kernel classes and methods • Application Proxies • Places parameters in registers • Causes appropriate software interrupt • Retrieves return value from register • Kernel Dispatchers • Retrieve pointer to the correct kernel object • Unmarshall input parameters • Make actual system call • Marshall the return value
Multithreading Overview • Thread lib resembles Java Thread • Relies on exceptions for error handling • Implemented inside sys lib instead of kernel
Thread Class Run(): Main function for threads. Automatically called when Start is called. class Thread { public: Thread(); virtual ~Thread(); virtual void Run()=0; void Start(); void Join(); … private: AppProc *AppProcObj; … }; Start(): Puts the thread into ready queue. Join(): Returns to caller when this thread finishes. AppProcObj: Kernel object that makes threading possible.
Thread Implementation • Rely on calls to IDL-gen’ed AppProc Obj class Thread { public: Thread(); void Start(); void Join(); … }; Application Process Obj Proxy Kernel Dispatcher User Kernel
POSIX vs. Choices (1 of 2) void *thread_work(void *args) { // cast args to input struct // unpack args } int main() { for (i=0;i<N;i++){ // pack thread args into t_args pthread_create(…,thread_work, t_args); } } class MyThread : public Thread { MyThread(arg1, …, argM); void Run() { //Similar to thread_work } } int main() { MyThread *thrds[N]; for (i=0;i<N;i++){ thrds[N]=new MyThread(arg1, …, argM); } for (i=0;i<N;i++){ thrds[N].Start(); } } POSIX Choices
POSIX vs. Choices (2 of 2) • POSIX Threads • Requires packing of args before creation • Requires unpacking of args in thread function • New thread is run right away • Choices Threads • Object-Oriented • Subclass of subclass of… threads • Args are attributes, no (un)packing • Separation of thread creation and scheduling
Multithread Demo
Conclusion • Compared with beginning of semester • Able to compile C++ program to run on Choices • Able to run multithreaded programs • Able to automate the system interface generation
Future Work • General Exceptions: Currently have a limited number of specific exceptions that can be passed from kernel to application • Performance Measurements: Test system calls on OMAP board, currently only working in Qemu
Thanks! Questions? cs523@googlegroups.com