Social Icons

Rabu, Desember 28, 2011

Operating System

                                                       OPERATING SYSTEM
INTRODUCTIONOperating systems are programs that manage computer hardware. Operating systems also providefoundation for application programs and acts as an intermediary between users withcomputer hardware.What does the Operating SystemA computer system can be divided into four parts, the hardware, operating system, programsapplications and the user (Figure 1.1).System and Application ProgramOperating SystemHardwareUsers UserFigure 1.1 Components of Computer SystemHardware parts, namely the Central Processing Unit (CPU), memory, input output (I / O devices) arebasic components in the process of calculation by the computer system. Application programs, such as wordprocessor, spreadsheed, compiler, and a web browser, a tool or how the infrastructurehardware will be used to solve problems that are owned by the user. Operating systemis the controlling and coordinating the use of hardware among various application programsthat exist.Viewpoint User (User)Setting the Operating System is based on the user's perspective, depending on the interfaceis used. In general, the Operating System on a computer system which only consists of Monitor, CPU,Keyboard, and Mouse is designed to let users (single user) to monopolize all the resourcesthere. Its main objective is to maximize the work is being done. Operating systemsattached to the computer system such as this, designed for ease of use with mostgreater emphasis on performance goals and a little on the utilization of resources (how many resourceshardware and software used for the common good).On mainframes or minicomputers, many users are connected to the system through terminalterminal.These users to exchange information and use system resources together.In such cases, the operating system used is designed for utilization of resources,maximize resources for CPU time, memory, I / O is used in an efficient and fair to eachthe user.There is also a model where the user uses worksation connected with other workstations,and server in a network. Each user has the resources on each workstationand also share resources with others such as networks, printers, and files. Systemoperating system on a circuit like this, built by combining resources and utilizationpersonal use of each user.Viewpoint SystemsFrom the standpoint of the system, the operating system is a program that most closely relate tothe hardware. In this connection, the operating system is considered as a resource allocator. A systemcomputers have a lot of resources needed to solve a problem, namely the CPUTime, memory, file strorage, I / O devices, and so on. Faced with so many conflictsdemand for use of resources, the operating system must determine howallocate these resources to a program and the user so that the computer system canrun efficiently and fairly.In addition, the operating system can also be emphasis on the needs of different kinds of control I / Odevices and programs that run user. In this position, the operating system is referred to as controlprogram (program controller). Control program to manage the execution of a program run by the userso there is no error and error use of computers, especially on the use of I / Odevices.Computer Systems OrganizationComputer System OperationModern general-purpose computers consisting of one or more cpu and some device controller thatconnected by bus (data path) as a provider of access to shared memory (Figure 1.2).Each device controller is connected to a particular function, such as disk drives, audio devices,and video displays. CPU and various kinds of device controller can be executed simultaneouslyand compete for the memory cycles. To ensure the order of accessing the sharedmemory, a memory controller is added as a means of synchronization.Figure 1.2 Modern computer systemsWhen a computer is turned on, for example, the system will require an initial program.Initial program or bootstrap program is usually simple and stored in Read Omly Memory(ROM) or Erasable Programmable Read-only Memory (EEPROM). The function of the bootstrap isperform the initialization of all aspects of systems, from CPU registers, device controllers, and memory.Bootstrap program must know how to load the operating system and execute the system.Based on these objectives, the bootstrap should be able to find and load him into the kernelthe operating system. Then the process begins executing the operating system its first and wait aevents (event) occurs.The emergence of an event is usually characterized by an interrupt from either hardware or software.Hardware can trigger an interrupt at any time by sending a signal to the CPU and usually throughthe system bus. While the software can perform an interrupt at any time via a special operation incall the system call.When the interrupt occurs, the CPU immediately stops what is being done and transferThe requested execution to the proper location. The location is referred to here usually have a start addresswhere the interrupt service routine is located.Figure 1.3 Interrupt process time line.Storage StructureThe computer program, when run should be at the main memory (main memory), which usuallydisesbut Random Access Memory (RAM), to be executed. Main memory is the only medialarge storage that can be directly accessed by the processor. Implementation of this memory is calledas Dynamic Random Access Memory (DRAM), which form a memory array in sizewords. Each of these words have each address. Interaction with memory occurs throughmechanism of load-store instruction to the specific address in memory. Load instructions move onewords from main memory into the CPU registers, while the store opposite.The series of instruction execution (instruction-execution cycle) begins taking instruction frommemory which is then placed in the instruction register. After the execution results can bereturned to the memory. For the record, memory only serves as a storage mediumwhich contains a series of addresses. It means he does not know how (by instrution counter, indexingor the other) or for what (instruction or data) circuit is formed.Ideally, it would be better if the software and data can reside in main memory forever.But unfortunately this can not be done because:1. Main memory is not large enough to be able to store the entire application and data.2. Mainmemory is a temporary storage medium that will lose all of its contents whencomputer is turned off.Due to above reasons, was made a second storage media (secondary storage) in addition to themain memory. Its main purpose is for storage of large amounts of datapermanent.The most common storage medium is a magnetic disk, which can be used to storeprograms and data. Most of the programs will be recorded in this place until the load into memory.Other examples of storage media is the cache memory, CD-ROMs, magnetic tapes, and so on.All storage media have the same basic functions, ie save the data tothen be used again. There are differences in speed, price, capacity, and longstorage (volatile). Figure 1.4 shows the composition of the storage medium based on speedand price.Figure 1.4 Composition of the storage media.In addition to price and speed, as already mentioned earlier, another factor is the long volatile.Volatile in question here is whether the data is lost when power is switched off or not. OnFigure 1.4 above, all the above elektronic disk storage media is volatile.I / O StructuresDepending on the device controller, there could be more than one device (device) is connected.For example, seven or more devices can be added to the small computer systems interface-(SCSI) controller. A device controller is set up some local buffer storage and special purposethe register. Device controller main task is to regulate the movement of data between devices in the controlwith local storage buffer. Generally each operating system has a device driver for each devicethe controller. Device driver then provides an interface for the operating system.When starting the operation of I / O, device drivers to load the registers related to the device controller. Devicecontroller then checks the contents of registers to determine what action needs to be done.Subsequently the data transfer from device to local buffer storage. Once the data transfer is completedevice controller tells the device driver via an interrupt that work has been completedcarried out. Device driver then returns control to the operating system, or providedata or a pointer if the requested operation before the reading.Figure 1.5 Employment of modern computer systemsThe above method works best if used for a small amount of data, but will generateoverhead when used for large data transfers, such as disk I / O. Completion of this problemis to use direct memory access (DMA). After penyestingan buffe, pointers, andcounter for I / O devices, device controllers directly transfer the entire block of data from local bufferstorage to memory without any intervention from the CPU anymore.Computer System ArchitectureSingle Processor SystemIn a single processor system, there is a CPU capable of executing a series of generalpurposeinstruction, including instruction from a user process. But in general,single processor is accompanied by a microprocessor that exist in each device. For example, ismicroprocessor that converts keystrokes on the keyboard into the code for latersent to the CPU (main processor). Microprocessor such as this, is a microprocessor that can not beon direct access by the CPU.Multiple Processor SystemMultiprocessor system is also called parallel systems or tightly coupled systems. This system has twoor more processors that share the bus and sometimes clock, memory, and other devices. Multiprocessor Systemshas three main advantages.The addition of throughput. With increasing processor, expected that more work can becompleted in a short time. Despite the fact that the ratio of the speed of the system with Nprocessor is not equal to N. When multiple processors working together, in part functionused so that all portions of the processor can run correctly. In addition, the use of sharedresources may also reduce the expected value of multiple processors.Economical in terms of numbers. Multiple processor system can cost less thansingle processor system with the same amount, because of multiple processor systems can shareshared resource, device, and power. If multiple programs use the same data, would be moreefficient if it is stored in one system with multiple processors than many single systemprocessor, karen does not require multiple copies of data.Increased reliability. If the function or command can be well distributed among severalprocessor, the failure of one processor will not be too influential on the performance of the system. Workthe failed processor can be replaced by other processors.Increased reability (increased resistance) of a computer system is critical in manythe application. The ability to continue to provide services (service) to the hardware stage is calledas graceful degradation. System that is able to work better than so-called degradation grecefulas a fault tolerant, where a system can suffer a failure at each of its components butstill capable of providing service. Fault tolerance requires a mechanism that allowserrors that occur can be detected, at diagnosis, and if possible improved.HP Nonstop System (formerly Tandem) using duplicate hardware and software forensure the system is still running. This system consists of many couples the CPU. Two processors ofa pair executing each instruction and then compare the results. If the resultsdifferent, then one CPU fails, and both the CPU is stopped. The process that wasexecuted and delivered to the couple's next CPU and instruction execution is repeated.There are two processing systems on multiprocessor systems. The first process is referred to asasymmetric multiprocessing in which each processor given a special job. A master processorcontrolling the specific duty to control the system, and other processors waiting for orders frommaster processor or particular tasks. The system uses a master-slave relationship.Master processor scheduling and allocating work to slave processors.Figure 1.6 Symmetric MultiprocessingThe most common system used is a symmetric multiprocessing (SMP), where all processorsworking on all parts of the operating system. One example is the Solaris SMP, the commercial versionof UNIX, which was developed by Sun Microsystems. A Solaris machine can be configured tousing a dozen processors are all running Solaris. The advantages of this system, many processescould walk together. N process can be well done if there are N CPUs, without experiencingsignificant loss in performance.Model for symmetric multiprocessing or asymmetric multiprocessing can be determined either byhardware or software. A special hardware can be used to distinguish meltipleprocessor or a software designed to create a slave master and the rest.More recent multiprocessor system called the Blade Server, where multiple processor boards,I / O boards, and networking boards placed on the same chassis. Different systems withclassics are multiprocessor each processor can boot (active) separately andrun the operating system itself.Exercise:1. What is the operating system?2. The emphasis of the Operating System from the viewpoint of the user (single user PC, mainframe, and clientserver).3. Operating system from the viewpoint of the system (resource allocator, program controller).4. Initial or bootstrap program.5. How the CPU executes the program from memory (instruction-execution cycle).6. The fundamental difference storage device.7. Operating mechanism of I / O (device drivers, device controllers, DMA)8. Excess Multiprocessor systems9. Fault tolerance10. Symmetric and assymentric multiprocessor system

DOS operating system

OPERATING SYSTEM DOS DOS HISTORYMS-DOS was created by a computer maker, named Seattle Computer Products (SCP) which is headed by Tim Patterson, who later recruited by Microsoft to develop a DOS-in 1980 as an operating system software with the name of Q-DOS (short for from Quick and Dirty Operating System), which subsequently was renamed 86-DOS, because the Q-DOS is designed to run on computers with Intel 8086 processor. Microsoft would buy a license with less than U.S. $ 50,000 price of the SCP, then changed its name to MS-DOS. Furthermore, when IBM was about to launch a personal computer called the IBM PC, Microsoft also sells licenses MS-DOS to IBM. Understanding DOSDOS is (are) operating system that uses command-line interface used by computer users in the decade of the 1980s. To boot the computer facilities and run some software applications, such as WAS and Lotus. DOS is still a lot of functions that are used today, especially in resolving some troubleshooting on computer hardware. Although it could also be done on a GUI-based operating system. The following DOS functions:1. Organize or control the computer activities2. Set the memory3. Set the process input and output data4. Management file5. Management directory Family bebrapa DOS divided into classes, namely:1. MS-DOS (Microsoft Disk Operating System), including the Tandy DOS,2. Compaq DOS, Q-DOS (Quick and Dirty Operating System) and several clones from MS-DOS operating system that was sold to makers of computer systems IBM PC / Compatible.3. IBM PC-DOS (International Business Machines Personal Computer Disk Operating System), which although still made by Microsoft, modified a little to be used by IBM PC computer.4. DR-DOS (Digital Research Disk Operating System), which is made by the makers of the operating system CP / M, Gary Kildall.5. Novell Personal Netware, the DR-DOS version which was sold to Novell as a company that houses the CP / M went bankrupt (Novell acquired Digital Research Incorporated).6. Caldera DOS, Novell Personal Netware is a version that was sold to Caldera Corporation.7. FreeDOS, DOS version is built from the remnants of the development of Caldera DOS, developed by the open source community.
 DEVELOPMENTIBM and Microsoft subsequently released versions of DOS, where the direct version of IBM PC bundled with the IBM computer called the "IBM PC-DOS" (short for International Business Machines Personal Computer Disk Operating System). At first, IBM only uses what is proper use of MS-DOS released by Microsoft, such as programs or utilities that inclusion. For this reason, IBM's version is always slower than the released version of MS-DOS. But, MS-DOS version 4.0 is the first version of MS-DOS that really the same as the IBM PC-DOS, because Microsoft is berkonsenstrasi to develop a successor to the DOS operating system, called OS / 2.Microsoft, when licensed DOS to IBM, signed a license agreement that contains one point that Microsoft may license the MS-DOS to companies other than IBM, and the company is welcome to change the name MS-DOS became the name they use (example: TandyDOS, Compaq DOS , and others). Many versions of course the same as the version that has been developed by Microsoft with MS-DOS, but Microsoft started to revoke the license agreement so that other companies should use the name MS-DOS, instead of names that have been previously customized. Only IBM provided the flexibility to continue using the name of the IBM PC-DOS, MS-DOS instead.MS-DOS was developed fairly quickly, with significant features are taken from some other operating systems like Microsoft Xenix-one variant of the UNIX operating system developed by Microsoft-and DR-DOS Digital Research, and other utility products such as Norton Utilities from Symantec Corporation (products adopted as Microsoft Disk Defragmenter), PC-Tools from Central Points (products adopted as Microsoft Anti-Virus), expanded memory manager or EMM (Expanded Memory Manager) QEMM from Quarterdeck (products adopted such as EMM386), compression of the disk (or disk compression) DriveSpace from Stac Electronics, and many other products adopted.When Intel Corporation introduces a new microprocessor called the Intel 80286, Microsoft and IBM started a new project substitute DOS operating system called OS / 2, which is essentially a version of MS-DOS running in protected mode (protected mode). But Microsoft left the project OS / 2 is to focus on the development of Microsoft Windows and Microsoft Windows NT. Digital Research makes a graphical interface called the GEM, but is less popular on the IBM PC or compatible computer. GEM has received its market on the ATARI ST machines, but eventually overtaken again by Microsoft with Windows version 3.0.
 MS-DOS VERSION
1. MS-DOS version 1.xxThis is where the initial version of MS-DOS was first released by Microsoft. The contents, of course very primitive and only contains the basic framework only: no display graphs for managing files, no support network. Anyway, the first version of DOS is clean frill. The first version of DOS supports only IBM PC Model 5150 and all supporting hardware, such as floppy disks only support single-side floppy disk with a size of 5 ½ inches with a capacity of only 160K.Interval of approximately one year, in which the public interest will be the product of IBM PC, Microsoft also made improvements to MSDOS, and emerged DOS version 1.1. Actually, this is caused by IBM to launch new products for the floppy disk drive floppy double-side with a size 5 ½ inches with a capacity of 320K. Use double-side for the floppy disk is very influential, because storage media can store twice as much compared with single-side floppy diskette. Do not laugh to see the capacity of floppy disks that are supported by MS-DOS 1.1. You will not get the capacity of tens of megabytes or gigabytes. Even the hard disk it is still rarely encountered in the microcomputer, the Apple III and the only who has it.After that, Microsoft appeared to sell MS-DOS to IBM competitors who make a kind of clone of the IBM PC 5150. Microsoft gave version 1.25. They are designed in such a way by using the philosophy of open-architecture, such as Apple and Commodore then clones of the IBM PC can be done. And that's why IBM PCs and clones IBM PC compatible with IBM PC is very successful in the market. This is the success of three companies: IBM, Intel, and of course Microsoft. Only, it was then eroded IBM's market by Compaq, Hewlett-Packard, and Dell Computer Corporation is making IBM PC clones.2. MS-DOS version 2.xxIn early 1983, IBM launched the IBM PC XT (Extended Technology), as the improvement of the IBM PC version of 5150. IBM PC XT equipped with a 10M hard disk, interface input / output serial type (RS-232 or better known as a COM interface), with a capacity of 128K RAM, a floppy disk drive 360K double-side and three expansion slots. Of course, the use of some new hardware such as hard disks, and floppy drives with a capacity of 360K (40K higher than the double-side version of the IBM PC 5150) requires an operating system, IBM and Microsoft did not disappoint. They readily and rapidly released MS-DOS version 2.0. Finally, the IBM PC XT is bundled with IBM PC-DOS 2.0.MS-DOS version 2.0 has many improvements from MS-DOS 1.1 is intended for IBM PC 5150. Among these are support for the use of a hierarchical directory structure (branching) like a tree whose root (root) and branches (branch). In addition, MS-DOS 2.0 also supports a variety of functions adopted from UNIX, as well as the use of I / O redirection (>,>>, <, <<) and the print spooler. Features the print spooler is a feature that can save the file to be printed in a memory buffer so that the file to be printed are not printed immediately, but saved first. The aim is that the printing process can take place more quickly, and users will not be bothered to print the entire file if the paper runs out, but just need a new paper and press the resume button to continue. While I / O redirection functions to perform input and output functions are performed from the command line. Besides these two features are adopted from the UNIX, DOS version 2.0 also allows you to install drivers for DOS, by integrating it in the configuration file CONFIG.SYS.Apparently, IBM PC XT computer was very successful: success even reached Japan. To support Japanese Kanji language, Microsoft decided to launch the MS-DOS version 2:05.In the same year, IBM launched the IBM PC Jr.. (Read: PC Junior). Unfortunately, unlike his brothers, the IBM PC Jr.. failed in the market. When launched, the IBM PC Jr.. using the IBM PC-DOS 2.1.3. MS-DOS versions 3.xxIBM launched the IBM PC-AT (Advanced Technology) in the summer of 1984. IBM PC AT computer using the Intel 80286 microprocessor (16-bit) 6MHz speed, memory capacity of 256K RAM, a floppy drive 1.2m 5 ¼ inches, a 20M hard disk, and color video card (CGA standards). Of course, Microsoft as a solid business partner to swiftly support the launch of the IBM PC-AT with also launched the latest version, MS-DOS 3.0. MS-DOS 3.0 supports all the capabilities of the IBM PC-AT, except for multi-tasking provided by the Intel 80286 processor capable of running in protected mode, of course.DOS 3.0 is the version that can support network function, although limited to the network with the concept of the working group (workgroup) and connected as a client on a server. Users can use networking technology created by IBM, Token Ring on the DOS operating system. DOS 3.0 also supports a floppy disk 3 ½-inch low-density capacity of 720K, while the DOS 3.3 supports floppy disk 3 ½-inch high-density capacity of 1.44M. In the DOS version 3 also supports a partition on the hard disk has a capacity of up to 32M, 12m higher than the DOS version 2.0.4. MS-DOS version 4.xxIn 1988, the operating system with graphical display began to mushroom. Microsoft also released Windows version 1.0 on Windows 1985 and version 2.0 in 1989. In the DOS version 4.0, Microsoft makes a DOS shell program with the name of Shell, which has a display such as DOS Executive's Windows version 1.0. At that time, there is a program that is also popular shell running on top of DOS operating system, with the name of the Norton Commander (NC) made by Peter Norton. By using the shell, users can more easily organize and archive files, and run the program, in one screen only. In addition, because the mouse can simplify the operation of computers, DOS Shell can also support it.Version 4.0 is a version of the most changes. The next version is the improved versions, and various additional utilities.5. MS-DOS version 5.xxIBM does not make a breakthrough, a new breakthrough in the microcomputer industry, which previously dominated the market because IBM has eaten little by little by its competitors, such as Compaq, Hewlett-Packard, and Dell, which also produces microcomputers compatible with IBM computers, because using the same design, and also the same microprocessors made by Intel Corporation. Here is Intel Corporation's successful, because the microprocessors used produced much more, due to demand more. Because computers are using microprocessors made by Intel Corporation, which caught the second successful is Microsoft with DOS. Many analysts argue that this is caused by the failure of IBM when they sell the IBM PC Jr.., And IBM Micro-architecture P/S2 with Channel Architecture (MCA). The MCA bus used by IBM P/S2 not use the concept of open-architecture as the ISA bus is also made by IBM but with an open-architecture. In addition, the expansion cards that use the MCA bus has a price relatively more expensive than the ISA bus which was widely used and became a standard, thereby slowing absorption in the microcomputer market.IBM have failed to extend the life of the IBM PC, but Microsoft continues to develop with the launch DOS MS-DOS version 5.0. Version 5.0 was released in 1991, and has many features that are much better, as well as device drivers can be installed on a memory area above 640K (HMA), using the parameters in the configuration file CONFIG.SYS DEVICEHIGH and LOADHIGH the autoexec file. BAT thus increase the possibility to run a program that requires conventional memory (640K of memory beginning of which is owned by the computer) is greater.For the problem of utility, Microsoft is adding a lot of utility in DOS versions 5.0 of this. Among these are ASCII text file editor named MS-DOS Editor (EDIT.COM) and QuickBasic programming language programs (QBASIC.EXE). This utility is intended to replace the editor-oriented "line by line", EDLIN.EXE that exist in DOS versions 4.0 and earlier.In addition to ASCII text file editor, Microsoft also made a utility to create a macro to speed up working with computers. The program is called DOSKEY.COM macro maker. When loaded, DOSKEY can create a macro and execute the macro. In addition, by using DOSKEY can simplify typing the same command with the previous command so that the problem of "tired of typing" the same command over and over again to be far more simple and easy. To do so, users can use the arrow keys up and down. Features like these are owned by the Command Prompt in Windows 2000/XP.Other utilities are also interesting is UNFORMAT.EXE and UNDELETE.EXE. Both are very useful utility to restore deleted files and formatted drives. UNDELETE.EXE similar programs such as the Recycle Bin in Windows 95 (and beyond), only they look a bit more complicated compared to the Recycle Bin that runs on Windows. In addition UNDELETE.EXE running on the command line, the DOS version 5.0 is also there MWUNDEL.EXE utility that runs on Windows version 3.0, so that the Recycle Bin feature can also be found in Windows 3.0.6. MS-DOS version 6.xxMS-DOS version 6.0 was released in 1993. This version has many additional utilities, such as Antivirus (MSAV.EXE), Virus Protection (VSAFE.COM) adopted from Central Point PC-Tools. In addition, there is also a utility to perform disk defragmentation (DEFRAG.EXE) adopted from Symantec Norton Utilities, a utility to check the hard disk of the file placement errors and damage (SCANDISK.EXE) instead Chkdsk.exe, and various improvements of utilities that existed before.In MS-DOS version 6.0 also includes a utility that can create a more efficient placement file with the name of DoubleSpace. However, a company that has a patent on it became so angry that requires Microsoft to court. Microsoft was defeated and deprived of any DoubleSpace utility DOS 6.20. Late 1994, Microsoft revised the DOS 6:20 with a similar utility but does not violate the patents of others under the name DriveSpace. MS-DOS is MS-DOS version 6.22.7. MS-DOS version 7.xxMS-DOS version 7.0 was released just months before Microsoft released Windows 95, a version of Windows that is completely independent of the MS-DOS. Actually, Windows 95 is not really 100% free of MS-DOS, it's just some of the functionality that previously was handled by MS-DOS kernel, are now handled by Windows. MSDOS.SYS file which in previous versions are binary files (programs), now just a plain text file, which contains the computer boot process only, and various line contains "xxx" with no apparent function.Not much improvement that occurred at 7:00 this DOS because some functions have been moved to Windows 95. Windows 95 is an additional version of Windows with Win-32 API and a redesigned desktop. Windows 95 has a control center from the Start Menu button on the bottom left corner of your screen. When a new supply of 2 months, Microsoft said profit is very considerable, since Windows 95 have been sold to more than 7 million copies.When Microsoft launched Windows 98, Microsoft also revised version of DOS to 7:10 with support for FAT32 file system that is much more efficient than FAT16 file system. The functionality of the MS-DOS owned too much trimmed 7:10. The result, in late 1999, Microsoft launched a new version of Windows, code-named Georgia (Windows Millennium Edition), which is really no DOS!Actually, the operating system without actually ever made by Microsoft's DOS prior to Windows NT, Windows NT only intended for minicomputers, network servers, mainframes, and workstations. Its use makes it very difficult complicated adopted by the beginners in the field of computers. COMMAND - COMMAND DOSDOS commands are commands that can be run on the DOS operating system. In the DOS operating system, there are two types of orders, namely:1) internal command (internal command), ie commands that have been incorporated into the COMMAND.COM (DOS command interpreter), so it can be directly executed by the DOS kernel, anywhere.2) The external command (external command), ie commands that are not included in COMMAND.COM, and requires an executable file (a DOS program) to be contained in the active directory. Collection of DOS commands:1. BREAK Sets checking key presses Ctrl + C or foil.2. CD or chdir Change current directory to another directory specified in the parameter. If executed with no parameters, then this command will display the location where the directory is on.3. CHCP If run without parameters, this command will display the code page (character set) in the form of figures that are being used. This command can also be used to change the code page for all devices that support the turn of a collection of characters.4. CLS Clear the screen and place the cursor at the left corner of the screen. This command has no parameters.5. COPY Copy one or more files from one location to another are determined. This command has two parameters, namely the parameters of the source file and destination to which files will be copied.6. CTTY This command will replace the terminal device (terminal device / tty) used to control the computer.7. DATE This command will display the current date. This command also can set the computer date.8. DEL or ERASE Delete the file specified in the parameter. Parameters can be either file or multiple file names compiled using wildcard characters.9. DIR If used without parameters, this command can display a list of the files and subdirectories contained in the active directory. This file has one parameter, namely the location of the directory where you want to display a list of directory contents.10. EXIT Exit from the shell and the secondary COMMAND.COM COMMAND.COM back to the primary. LH or LOADHIGH Loading a program into upper memory blocks.11. LOCK command allows direct access to your hard disk. This command is only available to the MS-DOS in Windows 95/98.12. Or MD mkdir Create a directory in the active directory.13. PATH Determine where the MS-DOS should look for files that can be executed as a program.14. PROMPT Change the MS-DOS command prompt.15. Rmdir or RD Removes an empty directory. Will fail if the directory contains files or other subdirectories. Use an external command DELTREE to remove a total of a directory tree.16. REN or RENAME Change the name of one or multiple files (with wildcard characters).17. SET Displays, delete or set environment variables. Generally, this command is inserted into the AUTOEXEC.BAT file.18. TIME Displays or sets the current time.19. TYPE Displays the contents of a file (in text form) into the standard output.20. UNLOCK disables access the hard disk directly. This command is only edimiliki by MS-DOS in Windows 95/98.21. VER Display version of the operating system used.22. VERIFY Telling the operating system in order to verify that the files are written to the storage medium has been completely written, and displays the status verification. This command is by default turned on by the MS-DOS.23. VOL Displays the name of the label of a volume or partition.


DASAR-DASAR PEMROGRAMAN C++



2.1.  Tipe Data Dasar
Data merupakan suatu nilai yang bisa dinyatakan dalam bentuk konstanta atau variabel. Konstanta menyatakan nilai yang tetap, sedangkan variabel menyatakan nilai yang dapat diubah-ubah selama eksekusi berlangsung,
            Data berdasarkan jenisnya dapat dibagi menjadi lima kelompok, yang dinamakan sebagai tipe data dasar. Kelima tipe data dasar adalah:
§  Bilangan bulat (integer)
§  Bilangan real presisi-tunggal
§  Bilangan real presisi-ganda
§  Karakter
§  Tak-bertipe (void), keterangan lebih lanjut tentang void dijelaskan dalam Bab V.
Kata-kunci yang berkaitan dengan tipe data dasar secara berurutan di antaranya adalah int (short int, long int, signed int dan unsigned int), float, double, dan char.
Tabel 2-1 memberikan informasi mengenai ukuran memori yang diperlukan dan kawasan dari masing-masing tipe data dasar.

Tipe          Total bit                Kawasan                                   Keterangan

char                8             -128 s/d 127                                karakter
int                32             -2147483648 s/d 2147483647    bilangan integer
float              32             1.7E-38 s/d 3.4E+38                    bilangan real presisi-tunggal
double          64             2.2E-308 s/d 1.7E+308                bilangan real presisi-ganda

 
Tabel 2-1. Ukuran memori untuk tipe data




 



Untuk tipe data short int, long int, signed int dan unsigned int, maka ukuran memori yang diperlukan serta kawasan dari masint-masing tipe data adalah sebagai berikut :

Tabel 2-2 Ukuran memori untuk tipe data int
 






Catatan :
§  Ukuran dan kawasan dari masing-masing tipe data adalah bergantung pada jenis mesin yang digunakan (misalnya mesin 16 bit bisa jadi memberikan hasil berbeda dengan mesin 32 bit).


2.2  Variabel
2.2.1 Aturan Pendefinisan Variabel
Aturan penulisan pengenal untuk sebuah variabel, konstanta atau fungsi yang didefinisikan oleh pemrogram adalah sebagai berikut :
§  Pengenal harus diawali dengan huruf (A..Z, a..z) atau karakter garis bawah ( _ ).
§  Selanjutnya dapat berupa huruf, digit (0..9) atau karakter garis bawah atau tanda dollar ($).
§  Panjang pengenal boleh lebih dari 31 karakter, tetapi hanya 31 karakter pertama yang akan dianggap berarti.
§  Pengenal tidak boleh menggunakan nama yang tergolong sebagai kata-kata cadangan (reserved words) seperti int, if, while dan sebagainya.


2.2.2 Mendeklarasikan Variabel
Variabel digunakan dalam program untuk menyimpan suatu nilai, dan nilai yang ada padanya dapat diubah-ubah selama eksekusi program berlangsung. Variabel yang akan digunakan dalam program haruslah dideklarasikan terlebih dahulu. Pengertian deklarasi di sini berarti memesan memori dan menentukan jenis data yang bisa disimpan di dalamnya.

Bentuk umum deklarasi variabel:


tipe daftar-variabel;
 
 


Pada pendeklarasian varibel, daftar-variabel dapat berupa sebuah variabel atau beberapa variabel yang dipisahkan dengan koma. Contoh:
     int var_bulat1;
     float var_pecahan1, var_pecahan2;


2.2.3 Memberikan Nilai ke Variabel
Untuk memberikan nilai ke variabel yang telah dideklarasikan, maka bentuk umum pernyataan yang digunakan adalah :


nama_variabel = nilai;
 
 


Contoh:
     int var_bulat = 10;
     double var_pecahan = 10.5;


2.2.4 Inisialisasi Variabel
Adakalanya dalam penulisan program, setelah dideklarasikan, variabel langsung diberi nilai awal. Sebagai contoh yaitu variabel nilai :

            int nilai;
nilai = 10;

Dua  pernyataan di atas sebenarnya dapat disingkat melalui pendeklarasian yang disertai penugasan nilai, sebagai berikut :

            int nilai= 10;

Cara seperti ini banyak dipakai dalam program C, di samping menghemat penulisan pernyataan, juga lebih memberikan kejelasan, khususnya untuk variabel yang perlu diberi nilai awal (diinisialisasi).


2.3 Konstanta
            Konstanta menyatakan nilai yang tetap. Berbeda dengan variabel, suatu konstanta tidak dideklarasikan. Namun seperti halnya variabel, konstanta juga memiliki tipe. Penulisan konstanta mempunyai aturan tersendiri, sesuai dengan tipe masing-masing.
§  Konstanta karakter misalnya ditulis dengan diawali dan diakhiri dengan tanda petik tunggal, contohnya : ‘A’ dan ‘@’.
§  Konstanta integer ditulis dengan tanda mengandung pemisah ribuan dan tak mengandung bagian pecahan, contohnya : –1 dan 32767.
§  Konstanta real (float dan double) bisa mengandung pecahan (dengan tanda berupa titik) dan nilainya bisa ditulis dalam bentuk eksponensial (menggunakan tanda e), contohnya : 27.5f (untuk tipe float) atau 27.5 (untuk tipe double) dan 2.1e+5 (maksudnya 2,1 x 105 ).
§  Konstanta string merupakan deretan karakter yang diawali dan diakhiri dengan tanda petik-ganda (), contohnya :“Pemrograman Dasar C”.


2.4 Operator
            Operator merupakan simbol atau karakter yang biasa dilibatkan dalam program untuk melakukan sesuatu operasi atau manipulasi, seperti menjumlahkan dua buah nilai, memberikan nilai ke suatu variabel, membandingkan kesamaan dua buah nilai.  Sebagian operator C tergolong sebagai operator binary, yaitu operator yang dikenakan terhadap dua buah nilai (operand). Contoh :

            a + b

Simbol + merupakan operator untuk melakukan operasi penjumlahan dari kedua operand-nya (yaitu a dan b). Karena operator penjumlahan melibatkan dua operator ini tergolong sebagai operator binary.

            -c

Simbol - (minus) juga merupakan operator. Simbol ini termasuk sebagai operator unary, yaitu operator yang hanya memiliki sebuah operand (yaitu c pada contoh ini).


2.4.1. Operator Aritmatika
§  Operator untuk operasi aritmatika yang tergolong sebagai operator binary adalah :
*          perkalian
/          pembagian
%          sisa pembagian
+          penjumlahan
-          pengurangan
§  Adapun operator yang tergolong sebagai operator unary.
            -          tanda minus
            +          tanda plus
            Contoh pemakaian operator aritmatika misalnya untuk memperoleh nilai diskriminan dari suatu persamaan kuadrat :  D = b2 – 4ac

/* File program : diskrim.c
 Menghitung diskriminan pers kuadrat  ax^2 + bx + c = 0 */

# include

main()
{
    float a,b,c,d;
    a = 3.0f;
    b = 4.0f;
    c = 7.0f;

    d = b*b-4*a*c;
    printf(“Diskriminan =%f\n”,d);
}


Contoh eksekusi :

Diskriminan = -84.000000


Operator yang telah dituliskan di atas, yang perlu diberi penjelasan lebih lanjut adalah operator sisa pembagian. Beberapa contoh berikut kiranya akan memperjelas makna dari operator ini .
·         Sisa pembagian bilangan 7 dengan 2 adalah 1 (7 % 2 à 1)
·         Sisa pembagian bilangan 6 dengan 2 adalah 0 (6 % 2 à 0)
·         Sisa pembagian bilangan 8 dengan 3 adalah 1 (8 % 3 à 2)

Kegunaan operator ini diantaranya bisa dipakai untuk menentukan suatu bilangan bulat termasuk ganjil atau genap, berdasarkan logika : “Jika bilangan habis dibagi dua (sisanya nol), bilangan termasuk genap. Sebaliknya, termasuk ganjil”.


2.4.2. Operator Penurunan dan Penaikan
            Masih berkaitan dengan operasi aritmatika, C menyediakan operator yang disebut sebagai operator penaikan dan operator penurunan, yaitu :

++    operator penaikan
--  operator penurunan

Operator penaikan digunakan untuk menaikkan nilai variabel sebesar satu. Penempatan operator terhadap variabel dapat dilakukan di muka atau di belakangnya, contohnya :

     x = x+1;
     y = y+1;

Bisa ditulis menjadi :

     ++x;
     --y;

atau :

            x++;
     y--;

bergantung pada kondisi yang dibutuhkan oleh pemrogram.  Di bawah ini adalah contoh yang akan menunjukkan perbedaan pemakaian dan hasil dari ++x dengan x++ (atau pemakaian y-- dengan –-y).





/* File program : pre_post.c
Contoh penggunaan pre & post Increment operator */
 
#include 
 
main()
{
    int count = 0, loop;
    
    loop = ++count;  /* count=count+1; loop=count; */
    printf("loop = %d, count = %d\n", loop, count);
    
    loop = count++;  /* loop=count; count=count+1; */
    printf("loop = %d, count = %d\n", loop, count);
}
 
 
Contoh eksekusi :
 
loop = 1, count = 1
loop = 1, count = 2


2.4.3. Prioritas Operator Aritmatika
            Tabel di bawah ini  memberikan penjelasan mengenai prioritas dari masing-masing operator. Operator yang mempunyai prioritas tinggi akan diutamakan dalam hal pengerjaan dibandingkan dengan operator yang memiliki prioritas lebih rendah.

Tabel 2.3 Tabel prioritas operator aritmatika dan urutan pengerjaannya
Prioritas                                           Operator                                                  urutan pengerjaan
Tertinggi                ( )                                       dari kiri ke kanan
!     ++    --    +    -                  dari kanan ke kiri *)
*     /     %                             dari kiri ke kanan
+     -                                   dari kiri ke kanan *)
Terendah              =     +=    -=    *=    /=    %=          dari kanan ke kiri


 
           



 







*)   Bentuk unary + dan unary memiliki prioritas yang lebih tinggi daripada bentuk binary + dan binary -


2.4.4. Operator Penugasan
            Operator penugasan (assignment operator) digunakan untuk memindahkan nilai dari suatu ungkapan (expression) ke suatu pengenal. Operator pengerjaan yang umum digunakan dalam bahasa pemrograman, termasuk bahasa C adalah operator sama dengan (=).  Contohnya :

            fahrenheit = celcius * 1.8 + 32;

Maka ‘=’ adalah operator penugasan yang akan memberikan nilai dari ungkapan : celcius * 1.8 + 32 kepada variabel fahrenheit.
            Bahasa C juga memungkinkan dibentuknya statemen penugasan menggunakan operator pengerjaan jamak dengan bentuk sebagai berikut :

pengenal1 = pengenal2 = … = ungkapan ;

Misalnya :


            a = b = 15;

maka nilai variabel ‘a ‘ akan sama dengan nilai variabel ‘b‘ akan sama dengan 15.


2.4.5 Operator Kombinasi (Pemendekan)

              C menyediakan operator yang dimaksudkan untuk memendekkan penulisan operasi penugasan semacam


            x = x + 2;
     y = y * 4;

menjadi

     x +=  2;
     y *=  4;

Daftar berikut memberikan seluruh kemungkinan operator kombinasi dalam suatu pernyataan serta pernyataan padanannya.

Tabel  2.4  Seluruh kemungkinan operator kombinasi dan padanannya


x +=  2;   kependekan dari x = x + 2;
x -= 2;      kependekan dari x = x - 2;
x *=  2;   kependekan dari x = x * 2;
x /=  2; kependekan dari x = x / 2;
x %=  2;   kependekan dari x = x % 2;
x <<= 2;   kependekan dari x = x << 2;
x >>= 2; kependekan dari x = x >> 2;
x &=  2;   kependekan dari x = x & 2;
x |=  2;   kependekan dari x = x | 2;
x ^=  2;   kependekan dari x = x ^ 2;
 
 










2.5. Menampilkan Data ke Layar
            Untuk keperluan menampilkan data/informasi, C menyediakan sejumlah fungsi. Beberapa di antaranya adalah berupa printf() dan putchar().


2.5.1. Fungsi printf()
            Fungsi printf() merupakan fungsi yang paling umum digunakan dalam menampilkan data. Berbagai jenis data dapat ditampilkan ke layar dengan memakai fungsi ini. Bentuk umum pernyataan printf() :

            printf(“string kontrol”,argumen1, argumen2,...);

String kontrol dapat berupa keterangan yang akan ditampilkan pada layar beserta penentu format (seperti %d, %f,%c). Penentu format dipakai untuk memberi tahu kompiler mengenai jenis data yang akan ditampilkan. Argumen sesudah string kontrol (argumen1, argumen2,...)adalah data yang akan ditampilkan ke layar. Argumen ini dapat berupa variabel, konstanta dan bahkan ungkapan. Misal :

            printf(“%d”,20);     /* argumen berupa konstanta */
     printf(“%d”,a);      /*argumen berupa variabel */
     printf(“%d”,a+20);      /*argumen berupa ungkapan */
Penentu format untuk data string atau karakter :


%c       untuk menampilkan sebuah karakter
%s       untuk menampilkan sebuah string

 
 



Untuk menampilkan data bilangan, penentu format yang dipakai berupa salah satu dari bentuk dalam Tabel 2.5.

Tabel 2.5 Penentu format pada printf()


 













 



Contoh di bawah ini akan menjelaskan perbedaan format %g, %e dan %f dalam menampilkan bilangan real.


/*File program : form_efg.c
Perbedaan format %g, %e dan %f  */

#include

main()
{
   float x = 251000.0f;

   printf(“Format e  => %e\n”, x);
   printf(“Format f  => %f\n”, x);
   printf(“Format g  => %g\n”, x);
}
Contoh eksekusi :

Format e => 2.510000e+005

Format f => 251000.000000
Format g => 251000

 

            Tampak bahwa penentu format %e menampilkan bilangan dalam bentuk eksponensial.  Jika penentu fomat yang digunakan berupa %f, bagian pecahan secara default akan ditampilkan dalam bentuk 6 digit.  Sedangkan jika digunakan penentu format %g, maka digit yang tak berarti tak akan ditampilkan.

            Untuk menentukan panjang medan yang disediakan bagi tampilan data, maka sesudah tanda % dalam penentu format dapat disisipi dengan bilangan bulat yang menyatakan panjang medan. 
§  Untuk data yang berupa bilangan bulat, misal pada :
            printf(“Abad %4d”, 20);
%4d menyatakan medan untuk menampilkan bilangan 20 adalah sepanjang 4 karakter.
printf(“Abad %4d”, 20);

 


§  Untuk data yang berupa bilangan real, spesifikasi medannya berupa
                  m = panjang medan
m.n
 
                                                      n = jumlah digit pecahan 
Contoh pada pernyataan :
       printf(“Harga : Rp %8.2f\n”, 500.0);
%8.2f menyatakan panjang medan dari bilangan real yang akan ditampilkan adalah 8 karakter dengan jumlah digit pecahan 2 buah.                  
       printf(“Harga : Rp %8.2f\n”, 500.0);


 






Kalau hanya jumlah digit pecahan yang perlu ditentukan, panjang medan tak perlu disertakan, misal :

     printf(“%.2f\n”, 600.0);
  printf(“%.2f\n”, 7500.25);

hasilnya :

  600.00
  7500.25

§  Untuk data yang berupa string, contoh :

printf(“%12s”, “Bahasa C”);

maka akan ditampilkan sebagai berikut


 


Tampak dalam berbagai jenis data di atas, penentu format yang mengandung panjang medan, secara default akan menampilkan data dalam bentuk rata kanan terhadap panjang medan yang diberikan.  Untuk data string yang biasanya dikehendaki untuk ditampilkan dalam bentuk rata kiri, maka sesudah tanda % pada penentu format %s perlu disisipkan tanda (minus), contoh :

      printf(“%-12s”, “Bahasa C”);

menyatakan bahwa string akan ditampilkan dalam medan dengan panjang 12 karakter dan diatur rata kiri.  Sehingga tampilan di atas berubah menjadi :


 


/* File program : formatpjg.c
Contoh penggunaan format panjang medan data */

#include

main()
{
     int nilai1 = 20;
     float nilai2 = 500.0f;
    
     printf("Abad %5d\n", nilai1);
     printf("%10.2f\n", nilai2);
     printf("%10s\n", "Bahasa C");
     printf("%-10s\n", "Bahasa C");
}

Contoh eksekusi :

Abad       20
       500.00
     Bahasa C

Bahasa C

________________________________________________________________________


2.5.2 Fungsi putchar()
            Fungsi putchar() digunakan khusus untuk menampilkan sebuah karakter di layar.  Penampilan karakter tidak diakhiri dengan perpindahan baris. 
Contoh :

            putchar(‘A’);

menghasilkan keluaran yang sama dengan

     printf(“%c”,’A’);


2.6. Memasukan Data dari Keyboard
            Data dapat dimasukan lewat keyboard saat eksekusi berlangsung. Untuk keperluan ini, C menyediakan sejumlah fungsi, di antaranya adalah scanf(), getchar().


2.6.1. Fungsi scanf()
            Fungsi scanf() merupakan fungsi yang dapat digunakan untuk memasukkan berbagai jenis data. Misalnya untuk memasukkan data jari-jari lingkaran pada contoh program lingkaran.c, maka penulisan

            radius = 20;

dapat diganti menjadi

            scanf(“%f”,&radius);

Selengkapnya, terlihat dalam contoh program di bawah ini.


/* File program : lingkaran.c
Menghitung keliling dan luas lingkaran */

#include

main()
{
     double radius, keliling, luas;
    
     printf("Masukkan jari-jari lingkaran : ");
     scanf("%lf",&radius);
    
     keliling = 2 * 3.14 * radius; /* PI = 3.14 */

     luas = 0.5 * 3.14 * radius * radius;
    
     printf("\nData lingkaran\n");
     printf("Jari-jari = %8.2lf\n", radius);
     printf("Keliling  = %8.2lf\n", keliling);
     printf("Luas      = %8.2lf\n", luas);
}


Contoh eksekusi :

Masukkan jari-jari lingkaran = 5

Data lingkaran
Jari-jari =      5.00
Keliling  =     31.40
Luas      =     39.25 

Bentuk scanf() sesungguhnya menyerupai fungsi printf(). Fungsi ini melibatkan penentu format yang pada dasarnya sama digunakan pada printf(). Secara umum bentuk scanf() adalah sebagai berikut :

            scanf(“string kontrol”, daftar_argumen);

Dengan string kontrol dapat berupa :
§  Penentu format
§  Karakter spasi-putih (white-space)
§  Karakter bukan spasi-putih
Penentu format menyatakan jenis data yang akan dibaca. Pada scanf() penentu format dapat berupa salah satu di antara yang ada pada daftar berikut :
Tabel 2.6  Penentu format scanf()



%c                    membaca sebuah karakter
%s               membaca sebuah string (dibahas pada bab vii)
%i atau %d    membaca sebuah integer desimal
%e atau %f       membaca sebuah bilangan real (bisa dalam bentuk eksponensial)
%o                    membaca sebuah integer oktal
%x                    membaca sebuah integer heksadesimal
%u                    membaca sebuah integer tak bertanda
l                                  awalan untuk membaca data long int (misal : %ld) atau untuk membaca data double (misal : %lf)
L                      awalan untuk membaca data long double (misal : %Lf)
h                      awalan untuk membaca data short int


 
 













            Pada bentuk scanf(), daftar_argumen dapat berupa satu atau beberapa argumen dan haruslah berupa alamat.  Misalnya hendak membaca bilangan real dan ditempatkan ke variabel radius, maka yang ditulis dalam scanf() adalah alamat dari radius.  Untuk menyatakan alamat dari variabel, di depan variabel dapat ditambahkan tanda & (tanda & dinamakan sebagai operator alamat).  Sehingga &radius menyatakan alamat dari radius.  Dalam bentuk yang lengkap :

            scanf(“%f”, &radius);

berarti (bagi komputer) : “bacalah sebuah bilangan real (%f) dan tempatkan ke alamat dari radius (&radius)”.


2.6.3 Fungsi getchar()
            Fungsi getchar() digunakan khusus untuk menerima masukan berupa sebuah karakter dari keyboard. Contoh :

            c = getchar();

maka variabel c akan berisi karakter yang diketikkan oleh user atau EOF (end of file) jika ditemui akhir dari file.




Kesimpulan :
·          Data merupakan suatu nilai yang bisa dinyatakan dalam bentuk konstanta atau variabel.
·          Konstanta menyatakan nilai yang tetap, sedangkan variabel menyatakan nilai yang dapat diubah-ubah selama eksekusi berlangsung,
·          Variabel yang akan digunakan haruslah dideklarasikan terlebih dahulu, adakalanya langsung dideklarasikan sekaligus diberi nilai (diinisialisasi).
·          Operator merupakan simbol atau karakter yang biasa dilibatkan dalam program untuk melakukan sesuatu operasi atau manipulasi
·          Operator yang terkait dengan operasi aritmatika antara lain adalah operator aritmatika, operator penurunan dan penaikan, operator penugasan (assignment) dan operator kombinasi (pemendekan)
·          Untuk menampilkan data/informasi ke layar digunakan fungsi printf() dan putchar().
·          Untuk memasukkan data melalui keyboard saat eksekusi berlangsung digunakan fungsi scanf() dan getchar().


Latihan :

1. Mengapa nama-nama variabel di bawah ini tidak valid ?
(a)    value$sum
(b)    exit flag
(c)    3lotsofmoney
(d)    char
 
2.      Berapakah hasil akhir dari program berikut :
#include
main()
{
     int a = 22;
    
          a = a + 5;
          a = a-2;
printf("a = %d\n", a);
                }
               
3.      Berapakah nilai x setelah pernyataan-pernyataan berikut dijalankan, apabila x bertipe int :
(a)    x = (2 + 3) – 10 * 2;
(b)   x = (2 + 3) – (10 * 2);
(c)    x = 10 % 3 * 2 + 1;

4.      Nyatakan dalam bentuk pernyataan :
(a)   
0,3xz
  2a
 
y = bx2 + 0,5x – c
(b)   y =

5.      Apa hasil eksekusi dari program berikut :
#include
main()
{
     char kar = ‘A’;
    
          kar = kar + 32;
     printf("%c\n",kar);
     }
 

Sample text

Sample Text