[gem5-dev] Change in gem5/gem5[master]: base: Provide a getter for Fiber::started boolean variable

2019-05-03 Thread Giacomo Travaglini (Gerrit)
Giacomo Travaglini has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/18648



Change subject: base: Provide a getter for Fiber::started boolean variable
..

base: Provide a getter for Fiber::started boolean variable

This can be used to check if the fiber has started its execution.

Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Signed-off-by: Giacomo Travaglini 
---
M src/base/fiber.cc
M src/base/fiber.hh
2 files changed, 8 insertions(+), 4 deletions(-)



diff --git a/src/base/fiber.cc b/src/base/fiber.cc
index 177459a..f4496b1 100644
--- a/src/base/fiber.cc
+++ b/src/base/fiber.cc
@@ -88,7 +88,7 @@

 Fiber::Fiber(Fiber *link, size_t stack_size) :
 link(link), stack(nullptr), stackSize(stack_size), guardPage(nullptr),
-guardPageSize(sysconf(_SC_PAGE_SIZE)), started(false), _finished(false)
+guardPageSize(sysconf(_SC_PAGE_SIZE)), _started(false),  
_finished(false)

 {
 if (stack_size) {
 guardPage = mmap(nullptr, guardPageSize + stack_size,
@@ -170,7 +170,7 @@
 if (_currentFiber == this)
 return;

-if (!started)
+if (!_started)
 createContext();

 // Switch out of the current Fiber's context and this one's in.
diff --git a/src/base/fiber.hh b/src/base/fiber.hh
index 4d95e03..ed95050 100644
--- a/src/base/fiber.hh
+++ b/src/base/fiber.hh
@@ -82,6 +82,10 @@
 ///
 bool finished() const { return _finished; };

+/// Returns whether the "main" function of this fiber has started.
+///
+bool started() const { return _started; };
+
 /// Get a pointer to the current running Fiber.
 ///
 static Fiber *currentFiber();
@@ -96,7 +100,7 @@
 /// mark itself as finished and switch to its link fiber.
 virtual void main() = 0;

-void setStarted() { started = true; }
+void setStarted() { _started = true; }

   private:
 static void entryTrampoline();
@@ -114,7 +118,7 @@
 unsigned valgrindStackId;
 #endif

-bool started;
+bool _started;
 bool _finished;
 void createContext();
 };

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18648
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Gerrit-Change-Number: 18648
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini 
Gerrit-MessageType: newchange
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: base: Provide a getter for Fiber::started boolean variable

2019-05-07 Thread Giacomo Travaglini (Gerrit)

Hello Gabe Black, Anthony Gutierrez,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/18648

to look at the new patch set (#2).

Change subject: base: Provide a getter for Fiber::started boolean variable
..

base: Provide a getter for Fiber::started boolean variable

This can be used to check if the fiber has started its execution.

Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Signed-off-by: Giacomo Travaglini 
---
M src/base/fiber.cc
M src/base/fiber.hh
M src/base/fiber.test.cc
3 files changed, 18 insertions(+), 5 deletions(-)


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18648
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Gerrit-Change-Number: 18648
Gerrit-PatchSet: 2
Gerrit-Owner: Giacomo Travaglini 
Gerrit-Reviewer: Anthony Gutierrez 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-MessageType: newpatchset
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: base: Provide a getter for Fiber::started boolean variable

2019-06-07 Thread Giacomo Travaglini (Gerrit)

Hello Gabe Black, Anthony Gutierrez,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/18648

to look at the new patch set (#4).

Change subject: base: Provide a getter for Fiber::started boolean variable
..

base: Provide a getter for Fiber::started boolean variable

This can be used to check if the fiber has started its execution.

Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Signed-off-by: Giacomo Travaglini 
---
M src/base/fiber.cc
M src/base/fiber.hh
M src/base/fiber.test.cc
3 files changed, 44 insertions(+), 4 deletions(-)


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18648
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Gerrit-Change-Number: 18648
Gerrit-PatchSet: 4
Gerrit-Owner: Giacomo Travaglini 
Gerrit-Reviewer: Anthony Gutierrez 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-MessageType: newpatchset
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

[gem5-dev] Change in gem5/gem5[master]: base: Provide a getter for Fiber::started boolean variable

2019-06-09 Thread Giacomo Travaglini (Gerrit)
Giacomo Travaglini has submitted this change and it was merged. (  
https://gem5-review.googlesource.com/c/public/gem5/+/18648 )


Change subject: base: Provide a getter for Fiber::started boolean variable
..

base: Provide a getter for Fiber::started boolean variable

This can be used to check if the fiber has started its execution.

Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Signed-off-by: Giacomo Travaglini 
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18648
Reviewed-by: Gabe Black 
Maintainer: Gabe Black 
Tested-by: kokoro 
---
M src/base/fiber.cc
M src/base/fiber.hh
M src/base/fiber.test.cc
3 files changed, 44 insertions(+), 4 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/fiber.cc b/src/base/fiber.cc
index 177459a..f4496b1 100644
--- a/src/base/fiber.cc
+++ b/src/base/fiber.cc
@@ -88,7 +88,7 @@

 Fiber::Fiber(Fiber *link, size_t stack_size) :
 link(link), stack(nullptr), stackSize(stack_size), guardPage(nullptr),
-guardPageSize(sysconf(_SC_PAGE_SIZE)), started(false), _finished(false)
+guardPageSize(sysconf(_SC_PAGE_SIZE)), _started(false),  
_finished(false)

 {
 if (stack_size) {
 guardPage = mmap(nullptr, guardPageSize + stack_size,
@@ -170,7 +170,7 @@
 if (_currentFiber == this)
 return;

-if (!started)
+if (!_started)
 createContext();

 // Switch out of the current Fiber's context and this one's in.
diff --git a/src/base/fiber.hh b/src/base/fiber.hh
index 4d95e03..ed95050 100644
--- a/src/base/fiber.hh
+++ b/src/base/fiber.hh
@@ -82,6 +82,10 @@
 ///
 bool finished() const { return _finished; };

+/// Returns whether the "main" function of this fiber has started.
+///
+bool started() const { return _started; };
+
 /// Get a pointer to the current running Fiber.
 ///
 static Fiber *currentFiber();
@@ -96,7 +100,7 @@
 /// mark itself as finished and switch to its link fiber.
 virtual void main() = 0;

-void setStarted() { started = true; }
+void setStarted() { _started = true; }

   private:
 static void entryTrampoline();
@@ -114,7 +118,7 @@
 unsigned valgrindStackId;
 #endif

-bool started;
+bool _started;
 bool _finished;
 void createContext();
 };
diff --git a/src/base/fiber.test.cc b/src/base/fiber.test.cc
index 7e7bfef..6276df2 100644
--- a/src/base/fiber.test.cc
+++ b/src/base/fiber.test.cc
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2019 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright 2018 Google, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,6 +37,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Authors: Gabe Black
+ *  Giacomo Travaglini
  */

 #include 
@@ -35,6 +48,29 @@

 #include "base/fiber.hh"

+/** This test is checking if the "started" member has its expected
+ * value before and after the fiber runs. In the test an empty fiber
+ * is used since we are just interested on the _started member and
+ * nothing more.
+ */
+TEST(Fiber, Starting)
+{
+class StartingFiber : public Fiber
+{
+  public:
+StartingFiber(Fiber *link) : Fiber(link) {}
+void main() { /** Do nothing */ }
+};
+
+StartingFiber fiber(Fiber::primaryFiber());
+
+ASSERT_FALSE(fiber.started());
+
+fiber.run();
+
+ASSERT_TRUE(fiber.started());
+}
+
 class SwitchingFiber : public Fiber
 {
   public:

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18648
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie9222b8076756363c9f82c1333c76a352bcaf817
Gerrit-Change-Number: 18648
Gerrit-PatchSet: 5
Gerrit-Owner: Giacomo Travaglini 
Gerrit-Reviewer: Anthony Gutierrez 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev