eventq.hh (12082:ffa559ffeecc) eventq.hh (12270:3d6437eb362d)
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * Copyright (c) 2013 Mark D. Hill and David A. Wood
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 528 unchanged lines hidden (view full) ---

537 * Temporarily migrate execution to a different event queue.
538 *
539 * An instance of this class temporarily migrates execution to a
540 * different event queue by releasing the current queue, locking
541 * the new queue, and updating curEventQueue(). This can, for
542 * example, be useful when performing IO across thread event
543 * queues when timing is not crucial (e.g., during fast
544 * forwarding).
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * Copyright (c) 2013 Mark D. Hill and David A. Wood
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 528 unchanged lines hidden (view full) ---

537 * Temporarily migrate execution to a different event queue.
538 *
539 * An instance of this class temporarily migrates execution to a
540 * different event queue by releasing the current queue, locking
541 * the new queue, and updating curEventQueue(). This can, for
542 * example, be useful when performing IO across thread event
543 * queues when timing is not crucial (e.g., during fast
544 * forwarding).
545 *
546 * ScopedMigration does nothing if both eqs are the same
545 */
546 class ScopedMigration
547 {
548 public:
547 */
548 class ScopedMigration
549 {
550 public:
549 ScopedMigration(EventQueue *_new_eq)
550 : new_eq(*_new_eq), old_eq(*curEventQueue())
551 ScopedMigration(EventQueue *_new_eq, bool _doMigrate = true)
552 :new_eq(*_new_eq), old_eq(*curEventQueue()),
553 doMigrate((&new_eq != &old_eq)&&_doMigrate)
551 {
554 {
552 old_eq.unlock();
553 new_eq.lock();
554 curEventQueue(&new_eq);
555 if (doMigrate){
556 old_eq.unlock();
557 new_eq.lock();
558 curEventQueue(&new_eq);
559 }
555 }
556
557 ~ScopedMigration()
558 {
560 }
561
562 ~ScopedMigration()
563 {
559 new_eq.unlock();
560 old_eq.lock();
561 curEventQueue(&old_eq);
564 if (doMigrate){
565 new_eq.unlock();
566 old_eq.lock();
567 curEventQueue(&old_eq);
568 }
562 }
563
564 private:
565 EventQueue &new_eq;
566 EventQueue &old_eq;
569 }
570
571 private:
572 EventQueue &new_eq;
573 EventQueue &old_eq;
574 bool doMigrate;
567 };
568
569 /**
570 * Temporarily release the event queue service lock.
571 *
572 * There are cases where it is desirable to temporarily release
573 * the event queue lock to prevent deadlocks. For example, when
574 * waiting on the global barrier, we need to release the lock to

--- 257 unchanged lines hidden ---
575 };
576
577 /**
578 * Temporarily release the event queue service lock.
579 *
580 * There are cases where it is desirable to temporarily release
581 * the event queue lock to prevent deadlocks. For example, when
582 * waiting on the global barrier, we need to release the lock to

--- 257 unchanged lines hidden ---