Welcome to the blog site of SQLServer.in

Archives for Administration category

Find the number of CPU’s through SQL query

Here are the three ways to find the number of CPU’s through SQL query.

Method 1

Exec xp_cmdshell ‘set NUMBER_OF_PROCESSORS’

This method read the processor count from command prompt.

Method 2

Exec xp_msver ‘processorcount’

This method read the processor count through xp_msver system procedure.

Method 3

Declare @key varchar(1000)
Declare @value varchar(1000)
EXEC master..xp_regread @rootkey=’HKEY_LOCAL_MACHINE’,@key=’SYSTEM\CurrentControlSet\Control\Session Manager\Environment\’,@value=’NUMBER_OF_PROCESSORS

This method read the processor count from the system registry entry.

How to find system uptime

We are often in need for dos cmds to find the system uptime. Here are the different methods, test it out…

1. systeminfo

2. net statistics workstation/server

3. uptime

VAS continued…

VAS continued…

Each process allocate VAS in the starting. As required, the VAS regions will be bind to the physical memory. This will be done by means of committing(using VirtualAlloc API), AWE mechanism, file mapping API’s etc.

Physical pages can be shared or private. If the same physical pages are shared accross different VAS, its called shared physical pages, else if only mapped to a single VAS, they are called private physical pages. The physical pages could be either in disk or ram. If its only from RAM, its referenced as working set or memory usage in windows task manager.

Working set shown in the perfrmon & task manger includes non private pages.

Working Set in Perfmon counter = Mem Usage in Task manager
Private Bytes in perfmon counter = Virtual Memory Size in Task Manager

Virtual Memory/ VAS

Virtual memory is a mechanism or system. This system deals with Virtual addresses from Virtual address space. Each process running under windows gets virtual memory addresses starting from 0 to 4,294,967,295 (2*32-1 = 4 GB), no matter how much RAM is installed on the system.

That is; each user process typically has 4gb virtual address space (VAS). User process could see only the VAS area, which will in turn map to physical memory. Virtual memory address makes the user process to think in such a way that at any point in time, user process can address more memory than the physical memory(RAM) available in the system. Also the user process will have the impression that all the memory it deals with are contiguous.

The map between the virtual address & physical memory is done using page table entries(PTE). Each user process will have a page table which is an internal data structure translate virtual address to its corresponding physical address. The page table tells the process where the page is stored, whether in the disk or in the ram. PTE are present in the main memory.

PTE will have the information, where the page is available. ie., whether the page is available in the disk of physical memory. If the page is not loaded into memory, the loaction of disk will be there in the PTEs.

If the page has to be loaded, a hard page fault will be triggered & the page will be loaded to the memory(ram). Once the page is in the RAM the PTE is updated to reflect the page frame number/location.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
 

About Author

Krishna is a Senior Database Administrator, having handson experience of 6 years. Areas of expertise includes database engine, Business Intelligence & performance tunning. A regular SQL blogger on his own website, msdn forums, sqlteam.com & believe in sharing his experience with other technology enthusiasts.