From a3f4f544395c9cd6f61a091ed0d336841f89eebd Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Thu, 7 Sep 2017 01:26:04 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=98=EB=AA=BB=EB=90=9C=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index f2d3ff3..5020e0b 100644 --- a/main.go +++ b/main.go @@ -15,8 +15,9 @@ import ( "sync" "syscall" "time" + "amuz.es/src/infra/cpu_ctrl/pid" - + "github.com/coreos/go-systemd/daemon" "github.com/shirou/gopsutil/cpu" ) @@ -93,7 +94,7 @@ func ReadTempeture(path string, senseChan chan<- float64, errorChan chan<- error } } -func CpuTempetureMonitoring(info *Processor,sampleDuration time.Duration, notifier chan<- TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) { +func CpuTempetureMonitoring(info *Processor, sampleDuration time.Duration, notifier chan<- TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) { defer waiter.Done() tempeturePathGlob := path.Join(info.TempeturePath, "temp?_input") ticker := time.Tick(sampleDuration) @@ -131,38 +132,37 @@ func CpuTempetureMonitoring(info *Processor,sampleDuration time.Duration, notifi func CpuTempetureScraper(processorCount int, notifier <-chan TempetureChange, errorChan chan<- error, ctx context.Context, waiter *sync.WaitGroup) { defer waiter.Done() var ( - P,I,D=1.5, 0.4, 2.0 - SetPoint=40.0 - SampleTime=time.Second - WindupGuard=96.0 - maxNoob,minNoob=0x64,0x4 + P, I, D = 1.5, 0.4, 2.0 + SetPoint = 40.0 + SampleTime = time.Second + WindupGuard = 96.0 + maxNoob, minNoob = 0x64, 0x4 ) - noobs := make([]int,processorCount) - controllers := make([]pid.Controller, 0,processorCount) - for i:=0 ;i maxNoob{ - adj_noob=maxNoob + if adj_noob > maxNoob { + adj_noob = maxNoob } - if noobs[change.Id]== adj_noob{ + if noobs[change.Id] == adj_noob { continue } - noobs[change.Id]=adj_noob + noobs[change.Id] = adj_noob fmt.Printf("cpu %d fan 0x%x\n", change.Id, adj_noob) args := make([]string, 0) @@ -195,7 +195,7 @@ func main() { exitSignal = make(chan os.Signal, 1) errorChan = make(chan error, 1) tempetureChange = make(chan TempetureChange) - sampleDuration = time.Second + sampleDuration = time.Second ) if processorCount == 0 { @@ -206,7 +206,7 @@ func main() { errorChan <- err } else { waiter.Add(1) - go CpuTempetureMonitoring(info,sampleDuration, tempetureChange, errorChan, ctx, waiter) + go CpuTempetureMonitoring(info, sampleDuration, tempetureChange, errorChan, ctx, waiter) } } waiter.Add(1)