Palloc.c palloc.h Page allocator, which hands out system memory in multiples of 4 kB See section A.2.2 Thread Functions, for more information. Switch.S switch.h Assembly language routine for switching threads. See A.2.1 struct thread and A.2 Threads for Thread.h defines struct thread, which you are likely to modify Much of your work will take place in these files. See section A.1.3 High-Level Kernel Initialization, for details. You might want to add your own initialization code Program." You should look over main() at least to see what Init.c init.h Kernel initialization, including main(), the kernel's "main Need to look at this code or modify it, but it's here in case you're curious. See section A.1.1 The Loader, for details. Kernel and arranges for start.S to be near the beginning of the The linker script used to link the kernel. See section A.1.2 Low-Level Kernel Initialization, Unlike the loader, this code isĪctually part of the kernel. Start.S Does basic setup needed for memory protection and 32-bit Loads it into memory, and jumps to start() in start.S. PC BIOS loads into memory and which in turn finds the kernel on disk, Assembles to 512 bytes of code and data that the Presenting this overview will give you a start on what code to look at. You will not need to modify most of this code, but the hope is that Here is a brief overview of the files in the threads directory. Īlternatives to stack allocation include the page allocator and the blockĪllocator (see section A.5 Memory Allocation). Structures as non-static local variables, e.g. Problems, such as mysterious kernel panics, if you declare large data Stack overflow, but it cannot do so perfectly. Warning: In Pintos, each thread is assigned a small, fixed-sizeĮxecution stack just under 4 kB in size. See section A.2.3 Thread Switching, for more information. Gets called is different from the switch_threads() that returns. System once you understand why and how the switch_threads() that You will notice that when one thread calls switch_threads(),Īnother thread starts running, and the first thing the new thread does Thread's address and state, and what procedures are on the call stack forĮach thread. Start out, and then single-step from there. You can set a breakpoint on schedule() to Using the GDB debugger, slowly trace through a context switch to see what Saves the state of the currently running thread and restores the state The mechanics of a context switch are in threads/switch.S, which Implemented in idle(), runs.) Synchronization primitives can forceĬontext switches when one thread needs to wait for another thread to do Thread is ready to run at any given time, then the special "idle" thread, The scheduler decides which thread to run next. Inside Pintos, with the function passed to thread_create()Īt any given time, exactly one thread is running, and the rest, if any,Īre inactive. Each thread, therefore, acts like a mini-program running Scheduled and runs, it starts from the beginning of that functionĪnd executes in that context. You provide a function to be run in this context as anĪrgument to thread_create(). When a thread is created, you are creating a new context to be You can also run the kernel in a debuggerĪnd set breakpoints at interesting spots, single-step through code and If you like, you can addĬalls to printf() almost anywhere, then recompile and run to see Of the source code to see what's going on. If you haven't alreadyĬompiled and run the base system, as described in the introduction Some of this code might seem slightly mysterious. Primitives (semaphores, locks, condition variables, and optimization Pintos already implements thread creation and thread completion,Ī simple scheduler to switch between threads, and synchronization The first step is to read and understand the code for the initial thread Skim the material from A.1 Loading through A.5 Memory Allocation, especially A.3 Synchronization. Compilation should be done in the threads directory.īefore you read the description of this project, you should read all of This assignment, with some work in the devices directory on the You will be working primarily in the threads directory for Your job is to extend the functionality of this system to gain aīetter understanding of synchronization problems. In this assignment, we give you a minimally functional thread system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |