Sunday, 22 November 2009

Debugging Tools for Windows


Debugging Tools for Windows - Overview

Looking for updates and drivers for your personal computer?

You can use Debugging Tools for Windows to debug drivers, applications, and services on systems that are running Windows NT 4.0, Windows 2000, Windows XP, Windows Server 2003, Windows Vista, or Windows Server 2008. You can also use Debugging Tools for Windows to debug the operating system itself. Versions of the Debugging Tools for Windows package are available for 32-bit x86, native Intel Itanium, and native x64 platforms.

The latest release of Debugging Tools for Windows is available for download (see the Using Debugging Tools for Windows section on this page). You can also install the package from the Windows Driver Kit (WDK), the Platform SDK, or a Customer Support Diagnostics CD.

Note: If you have a system with a 64-bit processor and you are debugging an application on it, you must use one of the native 64-bit packages.

---------------------------


Command

.loadby sos mscorwks

~*e!drstack

Tuesday, 31 March 2009

LINQPad



LINQPad

Tired of querying in antiquated SQL?

Well, you don't have to!  LINQPad lets you interactively query SQL databases in a modern query languageLINQ.  Kiss goodbye to SQL Management Studio!

LINQPad supports everything in C# 3.0 and Framework 3.5:

  • LINQ to SQL
  • LINQ to Objects
  • LINQ to XML

LINQPad is also a great way to learn LINQ: it comes preloaded with 200 examples from the book, C# 3.0 in a Nutshell.  There's no better way to experience the coolness of LINQ and functional programming.

And LINQPad is more than just a LINQ tool: it's a code snippet IDE that instantly executes any C#/VB expression, statement block or program. Put an end to those hundreds of Visual Studio Console projects cluttering your source folder!

Best of all, LINQPad standard edition is free and can run without installation (or with a low-impact setup). The executable is 3MB and is self-updating.


 Download LINQPad

Two download options:

Standalone Executable

Download LINQPad.exe
(right-click, Save As...)

Low-Impact Setup

Download setup.exe
  • Creates desktop shortcut
  • Creates .LINQ file association

Authenticode signed

Current Version: 1.32.3
Prerequisites | License

LINQPad Screenshot


Prerequisites

LINQPad requires .NET Framework 3.5.

If you have Visual Studio 2008 or Visual C# 2008 Express, then Framework 3.5 will already be installed. 

LINQPad supports SQL Express, SQL 2000, SQL 2005, and (with some limitations) SQL 2008.

License

LINQPad standard edition is free to download and use. Autocompletion is an optional extra.

LINQPad is not an open-source product and the source code is protected by standard copyright laws.  Nonetheless, you are free to disassemble the executable to satisfy your curiosity. The author provides no warranties, and accepts no liability for direct or consequential damages. Read full EULA

The code samples from C# 3.0 in a Nutshell are © O'Reilly Media Inc.



Thursday, 5 March 2009

Lock dữ liệu trong Oracle

Lock dữ liệu trong Oracle

Lock dữ liệu trong Oracle

Để ngăn chặn sự xung đột có thể xảy ra khi có nhiều transaction cùng truy cập vào một nguồn tài nguyên (table, row, bộ nhớ,...), Oracle đặt ra các cơ chế lock dữ liệu.

Theo mặc định thì Oracle sẽ tự động lock dữ liệu khi cần thiết mà không cần tới sự can thiệp của người dùng, gọi là lock ngầm định (implicit locking). Và khi tự động lock dữ liệu, Oracle luôn chọn cấp độ lock thấp nhất có thể được.

Bên cạnh đó, Oracle cũng cung cấp các câu lệnh để người dùng có thể tự lock dữ liệu khi cần, gọi là lock xác định (explicit locking).

1.Các chế độ lock

Oracle cung cấp hai chế độ lock như sau:
  • Exclusive lock (lock độc quyền): Chế độ lock này không cho phép các transaction khác thay đổi trên cùng một tài nguyên. Các transaction khác muốn thay đổi dữ liệu thì phải chờ cho tới khi dữ liệu được unlock. Khi một transaction đã lock độc quyền trên tài nguyên thì các transtaction khác không thể lock trên tài nguyên đó.
  • Share lock (lock chia sẻ): Chế độ lock này không cho phép các transaction khác tiến hành lock độc quyền nhưng vẫn cho phép chúng cùng lock chia sẻ trên một tài nguyên.
Ví dụ: Khi một transaction tiến hành sửa dòng có mã là 100 của bảng employees:
  • Dòng có mã 100 sẽ bị exclusive lock nên các transaction khác sẽ không thể chỉnh sửa dòng này.
  • Bảng employees sẽ bị share lock nên các transaction khác sẽ không thể cập nhật cấu trúc của nó (vì để thay đổi cấu trúc bảng thì cần phải tiến hành exclusive lock). Tuy nhiên các transaction khác vẫn có thể thay đổi các dòng khác của bảng employees (khi đó bảng employees sẽ bị nhiều share lock).
2.Thời hạn lock

Oracle không cung cấp lệnh unlock tài nguyên. Do đó, tài nguyên sẽ bị lock cho tới khi transaction lock nó kết thúc (commit hoặc roll back). Và chỉ sau khi transaction kết thúc thì những gì nó thay đổi trên dữ liệu mới được các transaction khác nhìn thấy.

Nếu tài nguyên bị lock sau một save point thì khi transaction được roll back về save point đó, tài nguyên trên sẽ được unlock. Tuy nhiên những transaction đang chờ tài nguyên này vẫn chưa được quyền chỉnh sửa nó mà phải chờ cho transaction kia (transaction đã lock tài nguyên) kết thúc hoàn toàn.

3.Chuyển đổi lock và leo thang lock

3.1.Chuyển đổi lock

Chuyển đổi lock là đưa lock ở mức thấp lên lock ở mức cao hơn.
Oracle sẽ chuyển đổi lock khi cần thiết. Ví dụ khi ta tiến hành lệnh SELECT với tùy chọn FOR UPDATE, Oracle sẽ lock các dòng bị ảnh hưởng ở mức độc quyền và lock bảng ở mức row share. Nếu sau đó ta tiếp tục cập nhật các dòng đã lock thì bảng sẽ được chuyển sang lock ở mức cao hơn là row exclusive.

Với các dòng được thêm, xóa, sửa thì Oracle sẽ lock chúng ở mức độc quyền. Đó là mức lock cao nhất nên không cần chuyển đổi nữa.

3.2.Leo thang lock

Một số hệ quản trị CSDL thường tiến hành leo thang lock khi có quá nhiều lock được thực hiện. Ví dụ: Khi ta lock nhiều dòng trong một bảng thì hệ quản trị CSDL sẽ tiến hành lock ở mức bảng. Cách này giúp giảm số lock phải quản lý nhưng sẽ khiến cho một số tài nguyên bị lock một cách không cần thiết.

Oracle không bao giờ sử dụng leo thang lock bởi vì cách này sẽ làm tăng khả năng xảy ra dead lock.

4.Dead lock

Dead lock xảy ra khi nhiều user cùng chờ các tài nguyên bị lock của nhau.
Ví dụ:
  • Thời điểm T1: user A tiến hành lệnh cập nhật dòng có mã 100 của bảng employees => dòng 100 đó bị lock độc quyền.
  • Thời điểm T2: user B tiến hành lệnh cập nhật dòng có mã 200 của bảng employees => dòng 200 đó bị lock độc quyền.
  • Thời điểm T3: user B tiến hành lệnh cập nhật dòng có mã 100 của bảng employees. Do dòng 100 đang bị lock độc quyền bởi user A nên user B phải chờ user A.
  • Thời điểm T4: user A tiến hành lệnh cập nhật dòng có mã 200 của bảng employees. Do dòng 200 đó đang bị lock độc quyền bởi user B nên user A phải chờ user B.
  • Như vậy hai user A và B sẽ phải chờ nhau mà không làm được gì khác => lock xảy ra.
Oracle tự phát hiện dead lock và sẽ rollback một trong các transaction bị dead lock, từ đó hủy bỏ các lock gây xung đột.

Để tránh dead lock, ta có thể đặt ra quy ước về thứ tự làm việc để luôn tiến hành lock các tài nguyên theo một thứ tự nào đó.

Thursday, 5 February 2009

Visual Basic Code Samples

Sample Queries (Visual Basic)

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Locating Sample Files.

To run this sample

  • Press F5.

Demonstrates

The Sample Queries project contains about 101 samples from each of these areas:

  • LINQ to Objects

  • LINQ to SQL

  • LINQ to DataSet

  • LINQ to XML

Run the project, and select the type of LINQ sample that you want to examine. Examine the options, and run each query that interests you. The output from the query and the source code is displayed on the interface of the application.