Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
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-fuse
Commits
0892090d
Commit
0892090d
authored
Dec 30, 2010
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically set the number of CPUs.
parent
94244f10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
example/main.go
example/main.go
+7
-3
fuse/misc.go
fuse/misc.go
+15
-0
No files found.
example/main.go
View file @
0892090d
...
...
@@ -6,8 +6,8 @@ import (
"fmt"
"os"
"flag"
"runtime"
)
func
main
()
{
// Scans the arg list and sets up flags
debug
:=
flag
.
Bool
(
"debug"
,
false
,
"print debugging messages."
)
...
...
@@ -27,7 +27,11 @@ func main() {
mountPoint
:=
flag
.
Arg
(
1
)
state
.
Mount
(
mountPoint
)
fmt
.
Printf
(
"Mounted %s on %s (threaded=%v, debug=%v)
\n
"
,
orig
,
mountPoint
,
*
threaded
,
*
debug
)
cpus
:=
fuse
.
CountCpus
()
if
cpus
>
1
{
runtime
.
GOMAXPROCS
(
cpus
)
}
fmt
.
Printf
(
"Mounted %s on %s (threaded=%v, debug=%v, cpus=%v)
\n
"
,
orig
,
mountPoint
,
*
threaded
,
*
debug
,
cpus
)
state
.
Loop
(
*
threaded
)
}
fuse/misc.go
View file @
0892090d
...
...
@@ -11,6 +11,7 @@ import (
"fmt"
"path"
"math"
"regexp"
"syscall"
"unsafe"
)
...
...
@@ -268,3 +269,17 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) {
}
return
}
func
CountCpus
()
int
{
var
contents
[
10240
]
byte
f
,
err
:=
os
.
Open
(
"/proc/stat"
,
os
.
O_RDONLY
,
0
)
defer
f
.
Close
()
if
err
!=
nil
{
return
1
}
n
,
_
:=
f
.
Read
(
contents
[
:
])
re
,
_
:=
regexp
.
Compile
(
"
\n
cpu[0-9]"
)
return
len
(
re
.
FindAllString
(
string
(
contents
[
:
n
]),
100
))
}
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