Download presentation
Presentation is loading. Please wait.
Published byBarnard Terry Modified over 9 years ago
1
A user level multi-threaded Particle simulator Supervisor: Joe Cordina Observer: Kurt Debattista
2
Joe CordinaUser Level Multi-threaded Particle simulator2 APT Advanced practical task serve the purpose of allowing students to design, implement and document a medium to large project Student initiative Understand task + design Research into possible solutions Work alone under supervisor’s guidance
3
Joe CordinaUser Level Multi-threaded Particle simulator3 Overview Designing and implementing a user- level multi-threaded particle-in-a-box simulator.
4
Joe CordinaUser Level Multi-threaded Particle simulator4 Literature Operating Systems II and Concurrent and Distributed Systems Slides Any basic mathematics textbook Any basic physics textbook
5
Joe CordinaUser Level Multi-threaded Particle simulator5 Assessment 50% Design/Implementation 30% Documentation/Inception Report 20% Presentation/Interview
6
Joe CordinaUser Level Multi-threaded Particle simulator6 Main issues of APT Implementation Learn how to use Mesh Provide a multi-threaded particle simulator 2D view of particles Provide example scenarios Calculate basic physics constants Benchmark your algorithms
7
Joe CordinaUser Level Multi-threaded Particle simulator7 Mesh Mesh is an advanced very fast user- level multi-threaded library written in C for CERN (Linux). It is user-level and thus we will try not to make use of system calls as much as possible. Memory requirements concerns will be of major focus.
8
Joe CordinaUser Level Multi-threaded Particle simulator8 Mesh (cont.) Your main header files are Mesh.h and Scheduler.h Main function provided by void Main(Thread* p, int argc, char** argv); void Exit(int code); A large selection of function calls are available to allow thread manipulation Note that threads can also have a priority
9
Joe CordinaUser Level Multi-threaded Particle simulator9 Mesh (cont.) #define Thread_Constructor(F,X...) Scheduler_ThreadConstructor((ThreadMain)(F),X) void Thread_Destructor(Thread*); void Thread_Stop(void); void Thread_Exit(void); void Thread_NewPriority(int priority); void Thread_SetPriority(Thread* p,int priority); int Thread_GetPriority(void); void Thread_Yield(void); void Thread_Preempt(void); void Thread_Join(Thread* process,...); void Thread_Spawn(Thread*,int priority); void Thread_Run(Thread*); void Thread_Runs(Thread* process,...); void Thread_Par(Thread* process,...); void Thread_PriPar(Thread* process,int priority,...); void Thread_SleepUntil(RealTime t); void Thread_Sleep(RealTime t); Thread* Scheduler_ThreadConstructor(ThreadMain main,int stack_size,int narguments,...);
10
Joe CordinaUser Level Multi-threaded Particle simulator10 Particle Simulator Using the threads package you will simulate the behavior of physical particles in a box. Threads are ideal where each thread performs small amounts of calculation Thus define box dimensions and let the particles loose in it starting from a random position.
11
Joe CordinaUser Level Multi-threaded Particle simulator11 Particle Simulator (cont.) Particles in physics have a well defined behavior Assume that all particles are point particles When they collide with a wall their angle of reflection equals angle of incidence. Each particle has a mass and a velocity (speed with direction)
12
Joe CordinaUser Level Multi-threaded Particle simulator12 Particle Simulator (cont.) Motion is governed by s x = x + v * t * cos a s y = y + v * t * sin a where sx is distance in x direction sy is distance in y direction v is velocity t is time a is the direction angle
13
Joe CordinaUser Level Multi-threaded Particle simulator13 Particle Simulator (cont.) Particles can also collide with each other Yet particles have also momentum and physics say that initial momentum should equal final momentum in a collision. Equations given with handouts Be careful when calculating theta to get final angle One of the main task is an efficient collision detection between the particles
14
Joe CordinaUser Level Multi-threaded Particle simulator14 2D view of particles You will be using the svgalib man svgalib will tell you all Compile using gcc –lvga vga_init(); vga_setmode(G640x480x256); Then you can use int vga_drawpixel(int x, int y);
15
Joe CordinaUser Level Multi-threaded Particle simulator15 2D view of particles The display should be synchronized to 60 frames a second (Bonus). Make your program decrease the frames per second depending on the load in the computer. For timing you can use the RealTime Library.
16
Joe CordinaUser Level Multi-threaded Particle simulator16 Basic Physics constants You can calculate the average speed of the particles, the speed distribution and the velocity distribution. You can calculate the temperature visible produced by your particles in real-time and you can compare it to the ideal one. The mean Kinetic Energy has to remain constant in a closed box When numbers are very large = (mv x 2 ) / N
17
Joe CordinaUser Level Multi-threaded Particle simulator17 Bonus Material Construct multiple scenarios Multiple boxes next to each other where each border can store part of the energy of one collision and then pass it on to the next particle that hits it A leaky box, where if a particle has energy above a certain value, it will escape away 3D equations and visualization of the system Hot walls which transfer constant energy to the particles but particles which have larger energy will still escape Dampening effect in the box Others you might think of or discussed with me Optimisation techniques on the algorithms Producing graphs of physics constants with time
18
Joe CordinaUser Level Multi-threaded Particle simulator18 Benchmarking Use the RealTime library to be able to benchmark the efficiency of your algorithms. This will give you time delays in the order of s.
19
Joe CordinaUser Level Multi-threaded Particle simulator19 Documentation Inception report (Friday 1 st March) Analysis/Design Work plan Report Detailed analysis of problem Discussion of solution (+ others considered) Detailed description of data structures and algorithms used
20
Joe CordinaUser Level Multi-threaded Particle simulator20 Presentation 15 minute presentation Material Content Knowledge of subject Clarity Interview Answer questions related to APT
21
Joe CordinaUser Level Multi-threaded Particle simulator21 Interaction Expect to report to supervisor every other week: Friday Who cannot attend must mail in progress report + work in progress demo First meeting Friday 1 st March
22
Joe CordinaUser Level Multi-threaded Particle simulator22 The end All the best! Good luck! Work hard!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.