I want to find the user who is doing most physical reads to the hard-disk and kill that user - oracle-xe

I want to find the user who is doing most physical reads to the hard-disk and kill that user. Can I have a SQL/PL script to do that in oracle xe?

Related

How does a computer boot up?

I understand that the computer loads the first sector of memory known as BIOS, which runs diagnostics on hardware and the proceeds to load the OS. I guess my question leans towards the hardware side. How does the computer know which memory to boot from (RAM, ROM, FLASH, etc). I understand the differences between memory and I understand computers boot from the hard drive, but Im attempting to make an 8 bit computer with a z80 microprocessor, which will need to boot from ROM or Flash memory. The only problem is that the processor reads only from whatever memory the address pins are connected to and there are no separate address pins for ram and rom. Its also impractical to run the system on rom or flash due to the much slower read/write time compared to ram. The z80 to the best of my knowledge doesnt have separate commands for reading from rom and ram, and it wouldnt matter even if it did because the ram will be blank upon powering up. How does a computer choose to read from rom only upon booting and then switch to ram once the OS has been loaded. Is it hardwired in using logic gates? And how does a computer choose to write to flash memory or a hard drive instead of ram once the OS has been loaded? Would flash memory be treated as a device? Or is this also hardwired into the motherboard using logic gates? Sorry for giving so much background, I just dont want you to waste your time explaining things Ive already grasped. Ive just researched this to a great extent and thought about it for hours on end and cant seem to figure it out, and everywhere Ive looked doesnt explain how the computer chooses which memory to read from, it just says that it does. Thanks
I'm not sure I'm answering what you are asking, but I'll give it a try.
Some computers (at least, IBM PC-compatible computers), after powering up, usually run this BIOS (Basic Input/Output System) program. For this to happen, to the best of my knowledge, the hardware must make the jump to this code, and this code must be accessible (that is, mapped) from the physical memory, since that's where the CPU will execute code from. So, a physical address space with some read-only areas where this code is hard-wired to would do the trick.
Once the BIOS code is running, it can select how to proceed next. It can copy a sector from a hard disk to memory, (or a bunch of data from a Flash drive) and then jump to it, or whatever. That's up to the BIOS writer.
I will try to explain the Pentium boot up process very briefly.
On the flash ROM mounted on the Motherboard. there is a small program called BIOS (basic input, output system). After pressing the power button the BIOS program is executed.
The BIOS contains low level software that performs the following operations :-
checks how much RAM is installed and if all other PCI and ISA buses peripherals are connected.
it checks if all IO devices are connected.
scans a list of boot devices and selects the boot devices based on BIOS configurations setup earlier by the user.
once the boot devices is selected. the first sector from the boot device is read into memory and executed. it contains a simple program which examines the partition table and selects the Active one (Holding the OS). The secondary bootloader is read from that partition. this loader then reads the OS from the partition into the memory and runs it. After running, the OS asks the BIOS for the configuration info for each device and configure the new devices (those have no stored configurations). after all devices configurations are set. they are delivered to the kernel. Then it initializes tables, background boot up processes and starts login program or GUI.

Instantly Shut Down/Sleep shortcut

How do I create a shortcut that instantly shuts down the computer in the same way the computer instantly shuts down when holding my power button for 4 seconds. This is for PC.
I tried creating a shortcut using shutdown /s /t 0 but it does not shut down instantly.
thanks.
You can't do that. That's a hardware feature (cuts power to the machine, doesn't really 'shut down').
While its not quite possible to achieve what you described as it is a hardware feature, I believe you can mimic the behavior by sending Emergency Shutdown request to system. The result would be immediate session shutdown which is comparable in time with holding the power button.
In Windows you can achieve this by using NtShutdownSystem and NtSetSystemPowerState.
There is a very nice article about this topic:
http://www.codeproject.com/Articles/34194/Performing-emergency-shutdowns
in Unix/Posix based system you should be able to do this by using:
echo 1 > /proc/sys/kernel/sysrq-trigger ;
echo o > /proc/sysrq-trigger
however you may need to obtain required privileges.

Do flock locks reset after a system restart?

Let's say the system powers down unexpectedly due to a power outage.
Are flock locks always considered to be "unlocked" when the system starts up?
On Linux, flock relies on fcntl(...) (file descriptors).
Asked another way: Is it unnecessary to manually call flock -u <lock_filename> when the system first starts up? (i.e. from cron #reboot)?
Update:
BSD flock man pages says:
Locks are on files, not file descriptors. That is, file descriptors
duplicated through dup(2) or fork(2) do not result in multiple instances
of a lock, but rather multiple references to a single lock.
My Linux guru friend here mentions that there is a kernel locks table (for file locks) (usually stored in memory) which disappears on a reboot.
And that the file lock is just there for as long as the process is running.
According to the linux man page:
Locks created by flock() are associated with an open file table entry.
This is a data structure in the kernels memory and not in the file system that may be on persistent disk storage.
Open files are closed when the process exits - thus flocks are valid only as long as a process holding it is running.

Windows Service or Tray/NotifyIcon?

I want to write an app that will, given some network input, simulate mouse movements, clicks, and keyboard input. How and Why i want to do that is a different discussion :-) What I'd like to hear from SO is what would be the preferable model for an app/service like this?
Should I make a windows service that
sits in the background running as
system?
or should I make a tray app that
sits in the tray listening and
manipulating the user's input?
I haven't started working on it, so some of the things I'd imagine would trip me up would have to do with the service not having an interactive session, and/or permissions.
Anything I should anticipate or keep in mind?
If you intend to run your code on Vista and Windows 7, a Windows service isn't going to be enough because they can't interact with user desktops anymore. If you're going to be manipulating user input, you'll need a program running in the user's session.
One alternative is to write a service for monitoring the network events, start the client when a user logs in, and use IPC to communicate between the two.
EDIT: NetworkService should suffice for service privileges.
As Aaron suggested, have a Windows service monitoring the network.
As for the IPC to the process in the user session, you can use WCF, and a named pipe is probably the best transport, but you need to design it the right way round in order to get across the session boundary. Make the Service process the WCF service, with a duplex contract: the user session process calls the service to register and then events are passed back to the user session process on the callback contract. See this question for an explanation of the issues.
Aaron gave all the arguments why you can't do without the tray app, but why add the complexity of a service communicating with the app through IPC ?
A service is useful when you need to have code running even when no user is logged in. This isn't the case here, right ?
Unless you have to manipulate the input of multiple users logged in at the same time, I would go with only the tray app doing both tasks of monitoring network events and manipulating user input, it's way simpler to me.

configure a PC to default on state

I am writing device software for a PC and for that, I want the PC to be usable as a device. When power is supplied, it should switch on without requiring to press the power button. There are power options in BIOS settings but it starts the PC only when its uncleanly shutdown. The other concern I have is how would unclean shutdown affect the hard disk, filesystem and the OS (XP or Linux).
What you need is another PC and one of these devices attached to it.
http://www.relaypros.com/mm5/merchant.mvc?Screen=CTGY&Store_Code=NCD&Category_Code=RS-232_Relay_Boards&gclid=CMna8_yOo5wCFQxM5QodWjoflQ
What you do is send this some RS232 commands for a quick closure on one of the relays. The relay is connected to the Power On pins of the computer you want to control.
You possibly could find another relay contact closure for AC current that allows you to close a relay when AC is flowing, but you would only want to for a brief second.
Unsafe shut downs can be quite detrimental depending where the filesystem state is in. It would be quite hard on the hardware too.
There is also the alternative of booting from the network device. A quick search led to some information on wikipedia. Also, there is something related called preboot execution environment which seem to be something like what you are looking for.
Some software options - these aren't exactly what you asked for, but they might help
Mac OS X: In the energy saver control pane's options tab, select "Restart automatically after a power failue. shutdown -hu now should then bring the system down but give you 5 minutes to remove power to simulate a dirty shutdown, and have the computer reboot automatically when power is restored. It's a slightly dirty shutdown anyway, I think. (ie, it doesn't log you off first)
Windows:
I don't have a windows machine so I can't try this, but you used to be able to tell windows not to power down the computer when you select shut down, but rather to put it in a safe state and display "It is now safe to turn off your computer". Perhaps you could then remove the power and have the bios believe it was a non-clean shutdown, and turn the machine on again when power is restored. There are some instructions on how to do this in Windows Server 2003 at the bottom of this microsoft help document. This forum discussion seems to suggest it might work on XP.
Linux: Not sure about this one, but maybe this website can help.
I haven't tried any of these, so no guarantees that they'll work or work safely.

Resources