CMPS-3600 Operating Systems
Lab-10
Phase-3 of semester project
Do your work in your Odin 3600/a folder. Get the starting program like this... Log on to Odin server. $ cd 3600 $ ./lab-start.sh $ cd a $ cp ../9/vrlab9.c vrphase3.c or $ cp ../9/readers.c vrphase3.c You should create a Makefile. We will program as much as we can together in class. ---------------------------------------------------- 1. Setup a pause key 2. Draw the text for "press W" 3. Create a child window on 'W' 4. Clear the child window of animation 5. Clear the child window of most text 6. Give child window a new title bar 7. Setup an IPC message queue in parent . ipckey . mymsg struct . IPC_RMID at program end 8. Send the message queue ID to the child, . in the command-line arguments of execve() 9. Start a thread running in the child 10. Listen for messages in the child's thread 11. Setup check_resize() and move_window() functions 12. Parent writes to message queue on child create 13. When parent moves window, put message in message queue 14. Child looks for two message types . collision and car passes stats . new window position Our goal is this...Press 'W' to get a child window. The child window will display the traffic statistics. The parent will no longer show the statistics. (when child is open) The child window may be opened and closed.
Please show the intersection passes in your child window.![]()
![]()
void check_resize(XEvent *e) { //ConfigureNotify is sent when the window is resized or moved. if (e->type != ConfigureNotify) return; XConfigureEvent xce = e->xconfigure; g.xres = xce.width; g.yres = xce.height; //The following line removed courtesy: student Michael Kausch //init(); if (child) { //store the child's position g.child_pos[0] = xce.x; g.child_pos[1] = xce.y; } if (!child) { // Translate the position coordinates. // Translating the window coordinates is documented here: // https://stackoverflow.com/questions/25391791/ // x11-configurenotify-always-returning-x-y-0-0 // Window root = DefaultRootWindow(g.dpy); Window chld; int x, y; XTranslateCoordinates(g.dpy, g.win, root, 0, 0, &x, &y, &chld); g.parent_pos[0] = x; g.parent_pos[1] = y; g.parent_dim[0] = xce.width; g.parent_dim[1] = xce.height; //parent sends its new position to the child. if (g.nchildren > 0) { mymsg.type = 2; mymsg.parent_pos[0] = g.parent_pos[0]; mymsg.parent_pos[1] = g.parent_pos[1]; mymsg.parent_dim[0] = g.parent_dim[0]; mymsg.parent_dim[1] = g.parent_dim[1]; msgsnd(mqid, &mymsg, sizeof(mymsg), 0); } } set_window_title(); usleep(1000); } void moveWindow(int x, int y) { //This will move the window to position x,y XMoveWindow(g.dpy, g.win, x, y); } //Some variables for global struct... int parent_pos[2]; int parent_dim[2]; int child_pos[2];
Files to be collected... 3600/a/vrphase3.c 3600/a/Makefile