Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
e7d549fb
Commit
e7d549fb
authored
Jul 16, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new (more fifo) schedulint algorithm
newproc will reuse dead procs SVN=127565
parent
44b8934d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
15 deletions
+37
-15
src/runtime/proc.c
src/runtime/proc.c
+34
-13
src/runtime/runtime.h
src/runtime/runtime.h
+3
-2
No files found.
src/runtime/proc.c
View file @
e7d549fb
...
@@ -35,8 +35,24 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
...
@@ -35,8 +35,24 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
sys
·
panicl
(
123
);
sys
·
panicl
(
123
);
}
}
// try to rip off an old goroutine
for
(
newg
=
allg
;
newg
!=
nil
;
newg
=
newg
->
alllink
)
if
(
newg
->
status
==
Gdead
)
break
;
if
(
newg
==
nil
)
{
newg
=
mal
(
sizeof
(
G
));
newg
=
mal
(
sizeof
(
G
));
stk
=
mal
(
4096
);
stk
=
mal
(
4096
);
newg
->
stack0
=
stk
;
newg
->
status
=
Gwaiting
;
newg
->
alllink
=
allg
;
allg
=
newg
;
}
else
{
stk
=
newg
->
stack0
;
newg
->
status
=
Gwaiting
;
}
newg
->
stackguard
=
stk
+
160
;
newg
->
stackguard
=
stk
+
160
;
sp
=
stk
+
4096
-
4
*
8
;
sp
=
stk
+
4096
-
4
*
8
;
...
@@ -56,8 +72,6 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
...
@@ -56,8 +72,6 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
newg
->
goid
=
goidgen
;
newg
->
goid
=
goidgen
;
newg
->
status
=
Grunnable
;
newg
->
status
=
Grunnable
;
newg
->
alllink
=
allg
;
allg
=
newg
;
//prints(" goid=");
//prints(" goid=");
//sys·printint(newg->goid);
//sys·printint(newg->goid);
...
@@ -67,18 +81,25 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
...
@@ -67,18 +81,25 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
G
*
G
*
select
(
void
)
select
(
void
)
{
{
G
*
gp
,
*
bestg
;
G
*
gp
;
bestg
=
nil
;
gp
=
m
->
lastg
;
if
(
gp
==
nil
)
gp
=
allg
;
for
(
gp
=
gp
->
alllink
;
gp
!=
nil
;
gp
=
gp
->
alllink
)
{
if
(
gp
->
status
==
Grunnable
)
{
m
->
lastg
=
gp
;
return
gp
;
}
}
for
(
gp
=
allg
;
gp
!=
nil
;
gp
=
gp
->
alllink
)
{
for
(
gp
=
allg
;
gp
!=
nil
;
gp
=
gp
->
alllink
)
{
if
(
gp
->
status
!=
Grunnable
)
if
(
gp
->
status
==
Grunnable
)
{
continue
;
m
->
lastg
=
gp
;
if
(
bestg
==
nil
||
gp
->
pri
<
bestg
->
pri
)
return
gp
;
bestg
=
gp
;
}
}
if
(
bestg
!=
nil
)
}
bestg
->
pri
++
;
return
nil
;
return
bestg
;
}
}
void
void
...
...
src/runtime/runtime.h
View file @
e7d549fb
...
@@ -105,11 +105,11 @@ struct G
...
@@ -105,11 +105,11 @@ struct G
{
{
byte
*
stackguard
;
// must not move
byte
*
stackguard
;
// must not move
byte
*
stackbase
;
// must not move
byte
*
stackbase
;
// must not move
byte
*
stack0
;
// first stack segment
Gobuf
sched
;
Gobuf
sched
;
G
*
alllink
;
// on allq
G
*
alllink
;
// on allq
G
*
qlink
;
// on wait q
G
*
qlink
;
// on wait q
int32
status
;
int32
status
;
int32
pri
;
int32
goid
;
int32
goid
;
byte
elem
[
8
];
// transfer element for chan
byte
elem
[
8
];
// transfer element for chan
};
};
...
@@ -119,6 +119,7 @@ struct M
...
@@ -119,6 +119,7 @@ struct M
uint64
morearg
;
// arg to morestack - must not move
uint64
morearg
;
// arg to morestack - must not move
uint64
cret
;
// return value from C - must not move
uint64
cret
;
// return value from C - must not move
G
*
curg
;
// current running goroutine
G
*
curg
;
// current running goroutine
G
*
lastg
;
// last running goroutine - to emulate fifo
Gobuf
sched
;
Gobuf
sched
;
Gobuf
morestack
;
Gobuf
morestack
;
byte
*
moresp
;
byte
*
moresp
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment