Tuesday, April 21, 2015

Related Work and idea

Research -->  fault prediction/avoidance จะสนใจใน fault
                -->  runtime verification สนใจในพฤติกรรมที่นำไปสู่ failure
                       เพราะ failure สามารถหลีกเลี่ยงได้  แม้จะเกิด fault ขึ้น

1.งานพวก Runtime verification มีจุดประสงค์เดียวกัน แต่ต่างกระบวนการสร้างกฏที่เกิดขึ้น
   เช่น สร้าง specification จากไดอะแกรมต่าง ๆ   สร้างจากการเรียนรู้  สร้างจาก code เป็นต้น
   ซึ่งจำเป็นต้องรู้ event ที่ทำให้ state ปกติ  และ event ที่ทำให้ state ไม่ปกติ

2. งาน fault prediction ที่ใช้ ฺBN
    -  ใช้จำนวน method call, จำนวนบรรทัดของโค้ดใน method และอื่นๆ เป็นพารามิเตอร์ สำหรับ BN ในการเรียนรู้
    -  ใช้ attribute ของระบบ เช่น
             redundancy  -->  รอขยายความ
            constrained-ness --> รอขยายความ
            personnel turnover  -->  รอขยายความ

   -  วิเคราะห์ algorithm แล้วนำมา combine เพื่อทำนาย error  แต่ใช้ระดับที่สูงกว่าข้อมูลจากโปรแกรม
   -  นำเสนอการเรียนรู้และวิเคราะห์หาสาเหตุของการเกิด failure แต่ใช้กับ CPU usage
   - ใช้ model และ algorithm เพื่อวิเคราะห์หา trace log และทำนาย  root cause (งานนี้ใช้เครื่องมือต่าง จุดประสงค์ต่าง)


การจะกำหนด event หรือ behavior ต้องรู้ relationship

relationship เก็บได้จาก  sources(document, specification, expert) or การเรียนรู้


   sources(document, specification, expert) or การเรียนรู้
                                        |
                                        |
                                       V
                              relationship
                                        |
                                        |
                                       V
                         event หรือ behavior

***
งานของกวาง  ใช้ Bayesian Network เพื่อสร้าง rule จาก behavior ของโปรแกรม เพื่อจับ failure และหลีกเลี่ยงก่อนที่เหตุการณ์จะเกิดขึ้น

โดย BN เรียนรู้ความสัมพันธ์ และความน่าจะเป็น (ใช้ WEKA)จาก log ของตัวแปร  แล้วจึงสร้างกฏขึ้นมา

1. Data collection  ใช้การ instrument code และเพิ่มตัวแปร "colliding" เพื่อเก็บ track ของ state ที่นิยามเอาไว้ว่าจะเกิด failure  (ข้อสังเกตส่วนของการเพิ่มตัวแปรมีผลต่อการทำงานของโปรแกรมหรือไม่) 
เก็บเพื่อเอาไปเป็นพารามิเตอร์ในการเรียนรู้


2. ใช้ BN เรียนรู้ว่า event ไหนที่จะนำไปสู่การเกิด failure

3.evaluation ทดสอบประสิทธิภาพของความสัมพันธ์ที่ได้

4. สร้าง rule  (ใช้ IF-THEN)







ความต่างของ fault กับ failure

failure  คือ ส่วนประกอบของพฤติกรรมของระบบ ที่ต่างไปจากพฤติกรรมที่ต้องการ

fault   คือ  เงื่อนไขที่ถ้าเกิดขึ้นแล้ว จะทำให้ระบบหรือส่วนของระบบทำงานล้มเหลว
 (ส่วนที่นิยามเพิ่มเติม ก็คือ เป็น root cause ของ failure)


- ถ้ามีพฤติกรรมที่เกิดขึ้นต่างจากที่ต้องการ  =  failure
- state ที่ไม่ปกติ                          =  failure

Begin again

"You got no second chances in life"

cr:Kazaam

Wednesday, October 31, 2012

ตัวอย่างโค้ดที่ใช้ ExecutorService


Example using ExecutorService:
public class TaskThreader {
    class DoStuff implements Callable {
       Object in;
       public Object call(){
         in = doStep1(in);
         in = doStep2(in);
         in = doStep3(in); 
         return in;
       }
       public DoStuff(Object input){
          in = input;
       }
    }

    public abstract Object doStep1(Object input);    
    public abstract Object doStep2(Object input);    
    public abstract Object doStep3(Object input);    

    public static void main(String[] args) throws Exception {
        ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
        ArrayList<Callable> tasks = new ArrayList<Callable>();
        for(Object input : inputs){
           tasks.add(new DoStuff(input));
        }
        List<Future> results = exec.invokeAll(tasks);
        exec.shutdown();
        for(Future f : results) {
           write(f.get());
        }
    }
}
โค้ดของคุณคนนี้ >> http://stackoverflow.com/users/95122/bobmcgee
- ExecutorService อยู่ใน package ของ java.util.concurrent 
-  Runtime.getRuntime().availableProcessors()  << อันนี้น่าสนใจ ทำให้เรียกหมายเลขจาก pool (รึป่าว อิอิ)
ดูอีกทีจ้ะ http://stackoverflow.com/questions/1223072/how-do-i-optimize-for-multi-core-and-multi-cpu-computers-in-java

Hyper Threading คืออะไร

Hyper Threading จะทำให้ซอฟท์แวร์สามารถใช้ ซีพียูเสมือนมี 2 ซีพียูใน 1 ซีพียูจริง โดยจากมุมมองของซอฟท์แวร์ จะหมายถึงระบบปฏิบัติการและโปรแกรมจะสามารถกำหนดให้โปรเซสหรือเทรดหลายเทรดไปที่โปรเซสเซอร์หลายๆ ตัวเสมือนเครื่องคอมพิวเตอร์เครื่องนั้นมีซีพียูหลายๆตัว เลยทีเดียว  และถ้ามองจากมุมของสถาปัตยกรรมคอมพิวเตอร์มันจะหมายถึงการสามารถทำ instructions จาก logical processors ทั้งสองตัวโดยใช้ทรัพยากรในการทำงานร่วมกันได้ 

(อันนี้ ลอกมาจาก http://httwww.vcharkarn.com/vblog/115394/1)

แล้ว core 2 duo ไม่เห็นเป็นซีพียู 2 ตัวหรอ .. เฮ้องง




ความแตกต่าง ของ cpu (intel)

ความแตกต่าง ของ cpu (intel)

*Dual Core มี 2core cpu ตัวเดียว รองรับ multitask (พูดง่าย ๆ ก็มี 2 แกน)
*Core Duo นั้นจะเป็นการ เอา หน่วยประมวลผล 2 ตัวมารวมเข้าด้วยกัน บนชิพ 1 ตัว มี L2 เป็นของตัวใครตัวมัน
*Core 2 Duo นั้น มีหลักการคล้าย ๆ กับ Core Duo แต่รวมเอา L2 ไว้ด้วยกัน 
 *Core i3 ก็มี 2 แกน เหมือน Core 2 Duo
Core 2 Duo และ Core i3 เป็น CPU แบบ Dual-Core เหมือนกัน
แต่ Core i3 มี 2 core 4 threads
 , Core i5 มี 4 core 4 threads,
Core i7 มี 4 core 8 threads
จะย้าย ตัว Memory Controller รวมเข้าไปในตัว CPU
มีผลทำให้ CPU ติดต่อกับ RAM และ VGA ได้รวดเร็วมากขึ้น

core i3 มี Hyper Threading 
core 2 duo ไม่มี Hyper Threading 

เออแน่ะ แล้วทีนี้ ไอ้เจ้า core i3 กับ core 2 duo มี 2 คอ เหมือนกันแล้วมันต่างกันยังไงล่ะเนี่ย :D

Monday, October 4, 2010

Tuesday, February 23, 2010

สองเจ้าพ่อแห่ง RV research

คำว่า "เจ้าพ่อ" อ.วรเศรษฐ ท่านพูดถึงใน presentation ของวิชาสัมนา

เราก็คิดว่าบุคคลสองท่านนี้น่าจะตรงกับศัพท์คำนี้ในความหมายของอาจารย์ได้ เลยฝาก homepage ของท่านทั้งสองไว้

เพื่อศึกษางานวิจัยของท่านได้สะดวกยิ่งขึ้น


Klaus Havelund

Eric Bodden

ใครอยากศึกษาข้อมูลเพิ่มเติมก็เชิญได้เลยนะคะ เพราะท่านทั้งสองยินดีมากที่จะเผยแพร่ ((คิดเองรึเปล่าเรา))

Sunday, January 31, 2010

Aspect Oriented Programming (AOP)

AOP เอาไว้แก้ปัญหาเรื่อง Cross cutting concern (เอาให้ง่าย ๆ ก็คือการตัดผ่านเฉพาะสิ่งที่สนใจ)

ตัวอย่างเช่นเราจะทำระบบอะไรสักอย่าง แล้วมี cross cutting concern ที่ตัดผ่านคลาสของเราหลายอย่าง เช่น security logging message, availability ต่างๆ เป็นต้น ซึ่งอาจจะเป็นทั้ง functional หรือ non-function requirement ของระบบก็ได้ค่ะ

แต่ในบางคลาส อาจจะมี แค่ logging แต่ไม่มี security ซึ่งใช้ concern พวกนี้ไม่เท่ากันก็ได้

เวลา implement ด้วยแนวทาง OOP จึงทำให้เกิดปัญหาต่างๆ คือ
- concern เหล่านี้ลากตัดผ่านกระจัดกระจาย ทั่วไปในงานเรา (scattering) บางงานใช้บ้าง ไม่ใช้บ้าง
- โค๊ดของงานเราในแต่ละ modular ยุ่งเหยิง (tangling) เพราะมัวแต่ไปจัดการเรื่อง cross cutting เหล่านี้

เมื่อเป็นเช่นนี้แ้ล้วก็ระบบก็จะมี low cohesive เกิด high coupling ไ่ล่ code ก็ยาก แ้ล้วก็ reuse ได้ยากอีกด้วย

แนวทางใหม่ที่นำเสนอขึ้นนั่นคือ AOP (Aspect Oriented Programming)ค่ะ

ซึ่งจะสร้าง โปรแกรมขี้นมาเป็น AOP เพื่อที่จะเขียนคลาสสำหรับ concern ที่มีการตัดผ่านระหว่างคลาสของระบบเรา
โดยแบ่งออกเป็น Aspect ต่างๆ และเขียนแยกออกจาก core concern แล้วก็สร้างกฎสำหรับบอกว่า แต่ละ Aspect นั้นจะลากตัดผ่านยังไงบ้าง กฎนี้เราเรียกว่า Weaving Rules เมื่อเราทำการ weaving ไปผ่านตัว Aspect Weaver เจ้า Aspect เหล่านี้ก็จะไปลากตัดผ่าน core concern ให้เราเองตามที่กำหนดไว้

อ้างอิง : http://www.blognone.com/node/1426

Tuesday, October 6, 2009

คำสำคัญ

(static)
�� อาจใช้ Tool ช่วยตรวจวิเคราะห์ เอกสารและโปรแกรม code
(dynamic)
�� ใช้ข้อมูลทดสอบระบบและสังเกตผลการทำงาน

event-based อันนี้อาจารย์ ดร.อุษา อธิบายซะเข้าใจเลย
คือเกิดเหตุการณ์ตามเงื่อนไขก่อนค่อยทำ ไม่ต้องเช็คทุกครั้งว่ามีการเปลี่ยนแปลงอะไรไปบ้าง

state-based งงอยู่นาน..ตอนนี้จะงงต่อไปรึป่าว
คือเช็คในเวลาที่มีการเปลี่ยนสถานะ

False Positive
เกิดขึ้นเมื่อระบบได้ระบุว่าการกระทำหนึ่งเป็นการบุกรุกแต่ที่แท้แล้วไม่ใช่

<< เอาไว้ศึกษาก่อนเรียน >>

Common types of computer bugs

* Conceptual error (code is syntactically correct, but the programmer or designer intended it to do something else)

# Maths bugs

* Division by zero
* Arithmetic overflow or underflow
* Loss of arithmetic precision due to rounding or numerically unstable algorithms

# Logic bugs

* Infinite loops and infinite recursion

# Syntax bugs

* Use of the wrong operator, such as performing assignment instead of equality test. In simple cases often warned by the compiler; in many languages, deliberately guarded against by language syntax

# Resource bugs

* Null pointer dereference
* Using an uninitialized variable
* Off by one error, counting one too many or too few when looping
* Access violations
* Resource leaks, where a finite system resource such as memory or file handles are exhausted by repeated allocation without release.
* Buffer overflow, in which a program tries to store data past the end of allocated storage. This may or may not lead to an access violation. These bugs can form a security vulnerability.
* Excessive recursion which though logically valid causes stack overflow

#Co-programming bugs

* Deadlock
* Race condition
* Concurrency errors in Critical sections, Mutual exclusions and other features of concurrent processing. Time-of-check-to-time-of-use (TOCTOU) is a form of unprotected critical section.

# Teamworking bugs

* Unpropagated updates; e.g. programmer changes "myAdd" but forgets to change "mySubtract", which uses the same algorithm. These errors are mitigated by the Don't Repeat Yourself philosophy.
* Comments out of date or incorrect: many programmers assume the comments accurately describe the code
* Differences between documentation and the actual product

[[อ่านที่นี่]]

Wednesday, September 30, 2009

survey paper

ทำการ survey paper ทั้งที .. ตอนแรกก็กะว่าจะสำรวจสัก 3-4 paper

มันก็จริงอยู่หรอก ทำไปทำมา .. มันก็ต้องดู paper อื่น ๆ วุ่นวายไปหมด
เพื่อจะหาความหมายของ Keyword บ้าง รึเพื่อจะเข้าใจสูตร rules ต่างๆ
อีกทั้งยังต้องอ่านบทความหรือแม้แต่หาความรู้จากเว็บทั้งหลายแหล่
อะไรต่อมิอะไรมากมายเลยทีเดียว เริ่มจะเก่งภาษาขึ้นบ้างแล้วนะเนี่ย
แต่ก็เพื่อให้เข้าใจ paper ที่เลือกมา survey ให้มากที่สุด .....เหนื่อยจริง ๆ T_T

+ Rule-Based Runtime Verification (2004) :: อันนี้ survey
+ Event-based runtime verification of Java programs (2005) :: อันนี้ survey
+ Rule systems for run-time monitoring: from Eagle to RuleR (2007) :: อ่านประกอบ

+ Calysto: Scalable and Precise Extended Static Checking (2008) :: อันนี้ survey (แหม อันนี้เกือบใหม่ ..ภูมิใจจัง)

Monday, September 21, 2009

symbolic execution

http://www.youtube.com/watch?v=azTVEwxN8zM&hl=th

LLVM

LLVM หรือชื่อเต็มๆ ว่า Low Level Virtual Machine ซึ่งเป็นสถาปัตยกรรม/เทคโนโลยีการแปลง code ในระดับล่างจริงๆ โดยโปรเจคนี้เริ่มต้นที่มหาวิทยาลัย Illinois และ Apple เข้ามาให้การสนับสนุนในการช่วยพัฒนามาตั้งแต่ปี 2005 และได้เริ่มใช้งานใน Leopard ในการช่วยแปลง code ทาง graphics สำหรับเครื่องแมคฯ รุ่นต่ำๆ ที่ไม่มี hardware เฉพาะทาง

LLVM compiler อาจจะเข้ามาเป็นส่วนหนึ่งของ Xcode ในอนาคตอันใกล้นี้ และอาจจะแทน GCC แบบสมบูรณ์แบบด้วย

ซึ่งผลของการใช้ LLVM นี้จะช่วยให้นักพัฒนาทำงานได้ง่ายขึ้น และโปรแกรมที่รันเร็วขึ้น "มาก" (ราคาคุยหรือเปล่าไม่รู้) ในฮาร์ดแวร์เดียวกัน

Monday, August 17, 2009

GCs (cont.)

อ่านอันนี้เข้าใจขึ้น http://en.wikipedia.org/wiki/Guarded_Command_Language

In pseudocode:

if a < b then c := True
else c := False

In guarded command language:

if a < b c := true
[] a ≥ b c := false
fi

Skip and Abort
Skip and Abort are very simple as well as important statements in the guarded command language. Abort is the undefined instruction: do anything. The abort statement does not even need to terminate. It is used to describe the program when formulating a proof, in which case the proof usually fails. Skip is the empty instruction: do nothing. It is used in the program itself, when the syntax requires a statement, but the programmer does not want the machine to change states.

Guarded Command

Guarded Commands
• Suggested by Dijkstra ปี 1975
• Purpose: to support a new programming methodology that supported verification (correctness) during development
• Basis for two linguistic mechanisms for concurrent programming (in CSP and Ada)
• Basic Idea: if the order of evaluation is not important, the program should not specify one


Selection Guarded Command
• Form
if ->
[] ->
...
[] ->
fi
fi เป็นการจบด้วยการ reverse word
• Semantics: when construct is reached,
– Evaluate all Boolean expressions
– If more than one are true, choose one non-deterministically
– If none are true, it is a runtime error (ถ้าเป็น false ทั้งหมดจะเกิด runtime eror)

If I = 0 - > sum := sum +i
[] i > j - > sum := sum + j
[] j >I - > sum := sum +i

*ถ้า if = 0 และ j > I โครงสร้างจะเลือก nondeterminate ระหว่างการกำหนดค่าที่ 1 กับ 3


Loop Guarded Command
• Form
do ->
[] ->
...
[] ->
od
• Semantics: for each iteration
– Evaluate all Boolean expressions
– If more than one are true, choose one non-deterministically; then start loop again
– If none are true, exit loop



Guarded Commands: Rationale
• Connection between control statements and program verification is intimate
• Verification is impossible with goto statements
• Verification is possible with only selection and logical pretest loops
• Verification is relatively simple with only guarded commands


อันนี้อ่านแล้วยังงง ๆ ไว้อ่านใหม่ :
http://www.ipl.t.u-tokyo.ac.jp/~hu/pub/teach/msp06/lec2.pdf

Tuesday, August 11, 2009

KU 2009



insert image testing.

photo by Ms.Usa Sammapun

first blog

....................